This commit is contained in:
@@ -143,6 +143,19 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case AyaType.Review:
|
||||||
|
{
|
||||||
|
ReviewBiz biz = ReviewBiz.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"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,38 +60,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// //DUPLICATE
|
|
||||||
// //
|
|
||||||
// internal async Task<Review> DuplicateAsync(long id)
|
|
||||||
// {
|
|
||||||
// var dbObject = await GetAsync(id, false);
|
|
||||||
// if (dbObject == null)
|
|
||||||
// {
|
|
||||||
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// var newObject = new Review();
|
|
||||||
// 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.Review.AnyAsync(m => m.Name == newUniqueName);
|
|
||||||
// } while (NotUnique);
|
|
||||||
// newObject.Name = newUniqueName;
|
|
||||||
// newObject.Id = 0;
|
|
||||||
// newObject.Concurrency = 0;
|
|
||||||
// await ct.Review.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 +114,42 @@ namespace AyaNova.Biz
|
|||||||
return putObject;
|
return putObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//UPDATE schedule only
|
||||||
|
//
|
||||||
|
internal async Task<bool> PutNewScheduleTimeAsync(ScheduleItemAdjustParams p)
|
||||||
|
{
|
||||||
|
Review dbObject = await ct.Review.SingleOrDefaultAsync(z => z.Id == p.Id);
|
||||||
|
if (dbObject == null)
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbObject.ReviewDate = p.Start;
|
||||||
|
|
||||||
|
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
|
||||||
//
|
//
|
||||||
@@ -275,6 +280,17 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Can't change Review date after completed
|
||||||
|
//user must set empty completed before changing start date if they really want to do this
|
||||||
|
if (!isNew && proposedObj.CompletedDate != null)
|
||||||
|
{
|
||||||
|
if (proposedObj.ReviewDate != currentObj.ReviewDate)
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.VALIDATION_NOT_CHANGEABLE, "ReviewDate");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Does the object of this Review actually exist?
|
//Does the object of this Review actually exist?
|
||||||
if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.AType, proposedObj.ObjectId, ct))
|
if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.AType, proposedObj.ObjectId, ct))
|
||||||
{
|
{
|
||||||
@@ -481,7 +497,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<ReviewBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<ReviewBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
|
|||||||
Reference in New Issue
Block a user