Exemple #1
0
 public static void UpdateModule(this ApplicationModule appModule, ApplicationModuleViewModel appModuleViewModel, string action = "add")
 {
     appModule.Id       = appModuleViewModel.Id;
     appModule.Name     = appModuleViewModel.Name;
     appModule.Url      = appModuleViewModel.Url;
     appModule.ParentId = appModuleViewModel.ParentId;
 }
 //[Authorize(Roles = "Create")]
 public HttpResponseMessage Create(HttpRequestMessage request, ApplicationModuleViewModel moduleViewModel)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             ApplicationModule newModule = new ApplicationModule();
             newModule.UpdateModule(moduleViewModel);
             _moduleService.Add(newModule);
             _moduleService.SaveChanges();
             var responseData = Mapper.Map <ApplicationModule, ApplicationModuleViewModel>(newModule);
             response = request.CreateResponse(HttpStatusCode.Created, responseData);
         }
         return response;
     }));
 }