public UserModulesResponse Delete(UserModules request) { Bm2s.Data.Common.BLL.User.UserModule item = Datas.Instance.DataStorage.UserModules[request.UserModule.Id]; Datas.Instance.DataStorage.UserModules.Remove(item); UserModulesResponse response = new UserModulesResponse(); response.UserModules.Add(request.UserModule); return response; }
public UserModulesResponse Get(UserModules request) { UserModulesResponse response = new UserModulesResponse(); List<Bm2s.Data.Common.BLL.User.UserModule> items = new List<Data.Common.BLL.User.UserModule>(); if (!request.Ids.Any()) { items.AddRange(Datas.Instance.DataStorage.UserModules.Where(item => (request.GrantorId == 0 || item.GrantorId == request.GrantorId) && (request.ModuleId == 0 || item.ModuleId == request.ModuleId) && (request.UserId == 0 || item.UserId == request.UserId) )); } else { items.AddRange(Datas.Instance.DataStorage.UserModules.Where(item => request.Ids.Contains(item.Id))); } var collection = (from item in items select new Bm2s.Poco.Common.User.UserModule() { Granted = item.Granted, Grantor = new UsersService().Get(new Users() { Ids = new List<int>() { item.GrantorId } }).Users.FirstOrDefault(), Id = item.Id, Module = new ModulesService().Get(new Modules() { Ids = new List<int>() { item.ModuleId } }).Modules.FirstOrDefault(), User = new UsersService().Get(new Users() { Ids = new List<int>() { item.UserId } }).Users.FirstOrDefault() }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder); response.ItemsCount = collection.Count(); if (request.PageSize > 0) { response.UserModules.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize)); } else { response.UserModules.AddRange(collection); } try { response.PagesCount = collection.Count() / response.UserModules.Count + (collection.Count() % response.UserModules.Count > 0 ? 1 : 0); } catch { response.PagesCount = 1; } return response; }
public UserModulesResponse Post(UserModules request) { if (request.UserModule.Id > 0) { Bm2s.Data.Common.BLL.User.UserModule item = Datas.Instance.DataStorage.UserModules[request.UserModule.Id]; item.Granted = request.UserModule.Granted; item.GrantorId = request.UserModule.Grantor.Id; item.ModuleId = request.UserModule.Module.Id; item.UserId = request.UserModule.User.Id; Datas.Instance.DataStorage.UserModules[request.UserModule.Id] = item; } else { Bm2s.Data.Common.BLL.User.UserModule item = new Data.Common.BLL.User.UserModule() { Granted = request.UserModule.Granted, GrantorId = request.UserModule.Grantor.Id, ModuleId = request.UserModule.Module.Id, UserId = request.UserModule.User.Id }; Datas.Instance.DataStorage.UserModules.Add(item); request.UserModule.Id = item.Id; } UserModulesResponse response = new UserModulesResponse(); response.UserModules.Add(request.UserModule); return response; }
public void Post() { this.Response = this.ConnectorHelper.Post(this.Request); this.IsFilled = true; }
public void Delete() { this.Response = this.ConnectorHelper.Delete(this.Request); this.IsFilled = true; }