コード例 #1
0
 public HttpResponseMessage Update(HttpRequestMessage request, MainServiceGroupViewModel mainServiceGroupVM)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             var dbMainServiceGroup = _mainServiceGroupService.GetById(mainServiceGroupVM.Id);
             dbMainServiceGroup.UpdateMainServiceGroup(mainServiceGroupVM);
             _mainServiceGroupService.update(dbMainServiceGroup);
             _mainServiceGroupService.Save();
             var responseData = Mapper.Map <MainServiceGroup, MainServiceGroupViewModel>(dbMainServiceGroup);
             response = request.CreateResponse(HttpStatusCode.Created, responseData);
         }
         return response;
     }));
 }
コード例 #2
0
 public HttpResponseMessage Create(HttpRequestMessage request, MainServiceGroupViewModel mainServiceGroupVM)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             var newMainServiceGroup = new MainServiceGroup();
             newMainServiceGroup.UpdateMainServiceGroup(mainServiceGroupVM);
             newMainServiceGroup.CreatedBy = User.Identity.Name;
             _mainServiceGroupService.Add(newMainServiceGroup);
             _mainServiceGroupService.Save();
             var responseData = Mapper.Map <MainServiceGroup, MainServiceGroupViewModel>(newMainServiceGroup);
             response = request.CreateResponse(HttpStatusCode.Created, responseData);
         }
         return response;
     }));
 }
コード例 #3
0
        public static void UpdateMainServiceGroup(this MainServiceGroup mainServiceGroup, MainServiceGroupViewModel mainServiceGroupVM)
        {
            mainServiceGroup.Id = mainServiceGroupVM.Id;

            mainServiceGroup.CreatedBy       = mainServiceGroupVM.CreatedBy;
            mainServiceGroup.CreatedDate     = mainServiceGroupVM.CreatedDate;
            mainServiceGroup.MetaDescription = mainServiceGroupVM.MetaDescription;
            mainServiceGroup.MetaKeyWord     = mainServiceGroupVM.MetaKeyWord;
            mainServiceGroup.Name            = mainServiceGroupVM.Name;

            mainServiceGroup.Status      = mainServiceGroupVM.Status;
            mainServiceGroup.UpdatedBy   = mainServiceGroupVM.UpdatedBy;
            mainServiceGroup.UpdatedDate = mainServiceGroupVM.UpdatedDate;
        }