public ActionResult SaveService(ServiceAbbreviatedModel service) { IServiceDto newService; if (!ModelState.IsValid) //validate model { TempData["MessageType"] = WebMessageType.Failure; TempData["Message"] = "Failed to save changes to service"; } try //update state { newService = AbbreviatedEntityUpdate.UpdateService(service, _portfolioService.GetService(service.Id)); //preserve service design documentation _portfolioService.ModifyService(UserId, newService, EntityModification.Update); } catch (Exception exception) { TempData["MessageType"] = WebMessageType.Failure; TempData["Message"] = $"Failed to save changes to service, error: {exception.Message}"; newService = new ServiceDto(); return(View("ShowServices", newService)); } TempData["MessageType"] = WebMessageType.Success; TempData["Message"] = "Successfully saved service"; return(View("ShowServices", newService)); }
/// <summary> /// preserve catalogable attributes /// </summary> /// <param name="src"></param> /// <param name="target"></param> /// <returns></returns> public static IServiceDto UpdateService(ServiceAbbreviatedModel src, IServiceDto target) { target.BusinessValue = src.BusinessValue; target.Popularity = src.Popularity; return(target); }