Exemplo n.º 1
0
        public ActionResult Edit(int id, ElementEditViewModel viewmodel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entity = _elementService.GetById(viewmodel.Id);
                    if (entity == null)
                    {
                        return(HttpNotFound());
                    }
                    Mapper.Map(viewmodel, entity);
                    _elementService.UpdateElement(entity);

                    Success($"<strong>{entity.DisplayName}</strong> was successfully updated.");
                    return(RedirectToAction("Index"));
                }
                return(View(viewmodel));
            }
            catch
            {
                return(View(viewmodel));
            }
        }