public async Task <ActionResult> UpdateAwardModal(UpdateAwardModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await AwardWriter.UpdateAward(model); if (!ModelState.IsWriterResultValid(result)) { return(View(model)); } return(CloseModalSuccess()); }
public async Task <IWriterResult> UpdateAward(UpdateAwardModel model) { using (var context = DataContextFactory.CreateContext()) { var award = await context.Award.FirstOrDefaultAsync(x => x.Id == model.Id); if (award == null) { return(new WriterResult(false, "Award not found")); } award.Name = model.Name; award.Description = model.Description; award.Icon = model.Icon; award.Level = model.Level; award.Status = model.Status; award.Rank = model.Rank; award.Points = model.Points; await context.SaveChangesAsync(); return(new WriterResult(true)); } }