Пример #1
0
        public async Task<ActionResult> Edit(int id)
        {
            var db = MaintDbContext;
            var entity = await db.Cultures.FirstOrDefaultAsync(x => x.CultureId == id);
            if (entity == null)
            {
                return HttpNotFound();
            }
            var model = new CultureEditModel();
            model.FromEntity(entity, false, ControllerContext);

            return Template(model.CreateTemplate(ControllerContext));
        }
Пример #2
0
        public async Task<ActionResult> Edit(CultureEditModel model, int id)
        {
            var db = MaintDbContext;
            var entity = await db.Cultures.FirstOrDefaultAsync(x => x.CultureId == id);
            if (entity == null)
            {
                return HttpNotFound();
            }
            model.FromEntity(entity, true, ControllerContext);

            if (!TryUpdateModel(entity, model))
            {
                return Template(model.CreateTemplate(ControllerContext));
            }
            await db.SaveChangesAsync();
            await SetFlashAsync(new FlashMessage
            {
                Text = MaintCultureTextResources.SuccessToSave,
                MessageType = FlashMessageType.Success,
            });

            return Template(model.CreateTemplate(ControllerContext));
        }