This commit is contained in:
@@ -80,6 +80,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
.Select(x => MakeWOSchedItem(x, p))
|
.Select(x => MakeWOSchedItem(x, p))
|
||||||
.ToListAsync());
|
.ToListAsync());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//REMINDERS
|
||||||
|
if (p.Reminders)
|
||||||
|
{
|
||||||
|
r.AddRange(await ct.Reminder.Where(x => ViewStart <= x.StopDate && x.StartDate <= ViewEnd).Select(x => MakeReminderSchedItem(x, p)).ToListAsync());
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(ApiOkResponse.Response(r));
|
return Ok(ApiOkResponse.Response(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +121,19 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case AyaType.Reminder:
|
||||||
|
{
|
||||||
|
ReminderBiz biz = ReminderBiz.GetBiz(ct, HttpContext);
|
||||||
|
var o = await biz.PutNewScheduleTimeAsync(ad);
|
||||||
|
if (o == false)
|
||||||
|
{
|
||||||
|
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||||
|
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||||
|
else
|
||||||
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, "Type", "Type not supported for adjustment"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, "Type", "Type not supported for adjustment"));
|
||||||
}
|
}
|
||||||
@@ -139,13 +159,19 @@ namespace AyaNova.Api.Controllers
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static long? EpochSeconds(DateTime? dt, int tzOffset = 0)
|
private static PersonalScheduleListItem MakeReminderSchedItem(Reminder v, PersonalScheduleParams p)
|
||||||
// {
|
{
|
||||||
// if (dt == null) return null;
|
var s = new PersonalScheduleListItem();
|
||||||
// DateTimeOffset dto = new DateTimeOffset((DateTime)dt);
|
s.Id = v.Id;
|
||||||
// return dto.ToUnixTimeMilliseconds() + (tzOffset * 60000);
|
s.Color = v.Color;
|
||||||
// }
|
s.TextColor = TextColor(v.Color);
|
||||||
|
s.Start = (DateTime)v.StartDate;
|
||||||
|
s.End = (DateTime)v.StopDate;
|
||||||
|
s.Type = AyaType.Reminder;
|
||||||
|
s.Name = v.Name;
|
||||||
|
s.Editable = true;//personal reminders are always editable
|
||||||
|
return s;
|
||||||
|
}
|
||||||
private static string ColorFromWOItem(ViewSchedulePersonalWorkOrder v, PersonalScheduleParams p)
|
private static string ColorFromWOItem(ViewSchedulePersonalWorkOrder v, PersonalScheduleParams p)
|
||||||
{
|
{
|
||||||
switch (p.ColorSource)
|
switch (p.ColorSource)
|
||||||
|
|||||||
@@ -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
|
//GET
|
||||||
@@ -145,6 +113,41 @@ namespace AyaNova.Biz
|
|||||||
return putObject;
|
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
|
//DELETE
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user