public BaseResponse BatchUpdateFilePrivilege(Requests.FileManagerRolePrivilege.BatchUpdateFilePrivilegeRequest request)
        {
            var response = new BaseResponse();

            try
            {
                int addCounter     = 0;
                int updatedCounter = 0;
                foreach (var item in request.BatchUpdateFilePrivilege)
                {
                    if (item.ProcessBlueprint_Id > 0 && item.RoleGroup_Id > 0)
                    {
                        var toUpdate = DataContext.FileManagerRolePrivileges.Find(item.ProcessBlueprint_Id, item.RoleGroup_Id);
                        if (toUpdate != null)
                        {
                            // put update code here
                            toUpdate.AllowBrowse              = item.AllowBrowse;
                            toUpdate.AllowCopy                = item.AllowCopy;
                            toUpdate.AllowCreate              = item.AllowCreate;
                            toUpdate.AllowDelete              = item.AllowDelete;
                            toUpdate.AllowDownload            = item.AllowDownload;
                            toUpdate.AllowMove                = item.AllowMove;
                            toUpdate.AllowRename              = item.AllowRename;
                            toUpdate.AllowUpload              = item.AllowUpload;
                            DataContext.Entry(toUpdate).State = EntityState.Modified;
                            updatedCounter++;
                        }
                        else
                        {
                            //put insert code here
                            var privilege = item.MapTo <FileManagerRolePrivilege>();
                            DataContext.FileManagerRolePrivileges.Add(privilege);
                            addCounter++;
                        }
                    }
                }
                DataContext.SaveChanges();
                response.IsSuccess = true;
                response.Message   = string.Format("{0} data has been added, {1} data has been updated", addCounter.ToString()
                                                   , updatedCounter.ToString());
            }
            catch (InvalidOperationException inval)
            {
                response.Message = inval.Message;
            }
            catch (ArgumentNullException arg)
            {
                response.Message = arg.Message;
            }
            return(response);
        }
 public ActionResult PrivilegeUpdate(MVCxGridViewBatchUpdateValues<FileManagerRolePrivilegeViewModel, int> updateValues)
 {
     int fileId = 0;
     List<FileManagerRolePrivilegeViewModel> models = new List<FileManagerRolePrivilegeViewModel>();
     //todo here is create connection to service update FileManagerPrivileges
     BatchUpdateFilePrivilegeRequest request = new BatchUpdateFilePrivilegeRequest();
     var datas = new List<UpdateFilePrivilegeRequest>();
     foreach (var item in updateValues.Update)
     {
         var privilege = item.MapTo<UpdateFilePrivilegeRequest>();
         datas.Add(privilege);
         fileId = item.FileId;
     }
     request.BatchUpdateFilePrivilege = datas.ToList();
     var response = ProcessBlueprintDataProvider.service.BatchUpdateFilePrivilege(request);
     var data = ProcessBlueprintDataProvider.service.GetPrivileges(new Services.Requests.ProcessBlueprint.GetProcessBlueprintPrivilegeRequest { FileId = fileId });
     if (data.IsSuccess)
     {
         models = data.FileManagerRolePrivileges.ToList().MapTo<FileManagerRolePrivilegeViewModel>();
     }
     return PartialView("_PrivilegePartial", models);
 }