Ejemplo n.º 1
0
 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;
     }));
 }
Ejemplo n.º 2
0
 public static void UpdateMdArea(this MdArea mdArea, MdAreaViewModel mdAreaVm)
 {
     mdArea.Name  = mdAreaVm.Name;
     mdArea.Alias = Common.HelperMethods.ToUnsignString(mdAreaVm.Name);
     mdArea.BotID = mdAreaVm.BotID;
 }