public bool AddCategoryToGroups(IEnumerable <ApplicationCateGroup> cateGroups, int groupId, bool add)
 {
     if (add)
     {
         foreach (var cateGroup in cateGroups)
         {
             _appCateGroupRepository.Add(cateGroup);
         }
     }
     else
     {
         foreach (var cateGroup in cateGroups)
         {
             _appCateGroupRepository.DeleteMulti(x => x.GroupId == cateGroup.GroupId && x.CategoryId == cateGroup.CategoryId);
         }
     }
     return(true);
 }
Example #2
0
 public HttpResponseMessage AddPermissionFile(HttpRequestMessage request, int checkedCateID, int groupID)
 {
     return(CreateHttpRespond(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             _applicationCateGroup.Add(new ApplicationCateGroup
             {
                 GroupId = groupID,
                 CategoryId = checkedCateID
             });
             _unitOfWork.Commit();
             response = request.CreateResponse(HttpStatusCode.OK);
         }
         return response;
     }));
 }