This commit is contained in:
2021-09-20 17:03:28 +00:00
parent 4231ffadd6
commit e1c1abeb60
2 changed files with 68 additions and 39 deletions

View File

@@ -60,38 +60,6 @@ namespace AyaNova.Biz
}
}
// ////////////////////////////////////////////////////////////////////////////////////////////////
// //DUPLICATE
// //
// internal async Task<Reminder> DuplicateAsync(long id)
// {
// var dbObject = await GetAsync(id, false);
// if (dbObject == null)
// {
// AddError(ApiErrorCode.NOT_FOUND, "id");
// return null;
// }
// var newObject = new Reminder();
// CopyObject.Copy(dbObject, newObject, "Wiki");
// string newUniqueName = string.Empty;
// bool NotUnique = true;
// long l = 1;
// do
// {
// newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObject.Name, l++, 255);
// NotUnique = await ct.Reminder.AnyAsync(m => m.Name == newUniqueName);
// } while (NotUnique);
// newObject.Name = newUniqueName;
// newObject.Id = 0;
// newObject.Concurrency = 0;
// await ct.Reminder.AddAsync(newObject);
// await ct.SaveChangesAsync();
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
// await SearchIndexAsync(newObject, true);
// await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
// await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
// return newObject;
// }
////////////////////////////////////////////////////////////////////////////////////////////////
//GET
@@ -145,6 +113,41 @@ namespace AyaNova.Biz
return putObject;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//UPDATE schedule only
//
internal async Task<bool> PutNewScheduleTimeAsync(ScheduleItemAdjustParams p)
{
Reminder dbObject = await ct.Reminder.SingleOrDefaultAsync(z => z.Id == p.Id);
if (dbObject == null)
{
AddError(ApiErrorCode.NOT_FOUND, "id");
return false;
}
dbObject.StartDate = p.Start;
dbObject.StopDate = p.End;
await ValidateAsync(dbObject, dbObject);
if (HasErrors) return false;
try
{
await ct.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!await ExistsAsync(dbObject.Id))
AddError(ApiErrorCode.NOT_FOUND);
else
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
return false;
}
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, dbObject.AyaType, AyaEvent.Modified), ct);
await HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, dbObject);
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//DELETE
//