public bool UpdateFigureType(FigureTypeViewModel figureTypeViewModel) { try { var figureType = _context.Figures.FirstOrDefault(e => e.FigureId == figureTypeViewModel.FigureTypeId); if (figureType == null) { _context.Figures.Add(new Figure { FigureType = figureTypeViewModel.FigureTypeName }); } else { figureType.FigureType = figureTypeViewModel.FigureTypeName; _context.Figures.Update(figureType); } _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public ActionResult UpdateFigureType(FigureTypeViewModel model) { if (!ModelState.IsValid) { return(PartialView(model)); } var isFigureTypeUpdated = _historyRepository.UpdateFigureType(model); return(Json(new { success = isFigureTypeUpdated })); }