public HttpResponseMessage CreateUpdateArea(HttpRequestMessage request, MdAreaViewModel mdAreaVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadGateway, ModelState); return response; } MdArea mdArea = new MdArea(); if (mdAreaVm.ID == null) { mdArea.UpdateMdArea(mdAreaVm); _moduleSearchEngineService.CreateArea(mdArea); } else { var mdAreaDb = _moduleSearchEngineService.GetByAreaId(mdAreaVm.ID ?? default(int)); mdAreaDb.UpdateMdArea(mdAreaVm); _moduleSearchEngineService.UpdateArea(mdAreaDb); } _moduleSearchEngineService.Save(); response = request.CreateResponse(HttpStatusCode.OK, mdArea); return response; })); }
public MdArea CreateArea(MdArea area) { return(_mdAreaRepository.Add(area)); }
public void UpdateArea(MdArea area) { _mdAreaRepository.Update(area); }
public static void UpdateMdArea(this MdArea mdArea, MdAreaViewModel mdAreaVm) { mdArea.Name = mdAreaVm.Name; mdArea.Alias = Common.HelperMethods.ToUnsignString(mdAreaVm.Name); mdArea.BotID = mdAreaVm.BotID; }