예제 #1
0
        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());
        }
예제 #2
0
        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));
            }
        }