public async Task <WrapperUserAuthInfoListVM> Delete(UserAuthInfoVM itemTemp) { IEnumerable <UserAuthInfo> itemTask = await _repositoryWrapper.UserAuthInfo.FindByConditionAsync(x => x.Id == itemTemp.Id && x.FactoryId == itemTemp.FactoryId); var item = itemTask.ToList().FirstOrDefault(); if (item == null) { return(new WrapperUserAuthInfoListVM()); } _repositoryWrapper.UserAuthInfo.Delete(item); await _repositoryWrapper.UserAuthInfo.SaveChangesAsync(); this._utilService.LogInfo("Successful In Deleting Item Cateory"); var dataParam = new GetDataListVM() { FactoryId = itemTemp.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperUserAuthInfoListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperUserAuthInfoListVM> GetListPaged(GetDataListVM dataListVM) { System.Linq.Expressions.Expression <Func <UserAuthInfo, bool> > globalFilterExpression = (x) => true; if (string.IsNullOrEmpty(dataListVM.GlobalFilter) || string.IsNullOrWhiteSpace(dataListVM.GlobalFilter)) { globalFilterExpression = (x) => true; } else { globalFilterExpression = (x) => x.UserName.Contains(dataListVM.GlobalFilter); } var itemCatagoryList = await _repositoryWrapper.UserAuthInfo .FindAll() .Where(x => x.FactoryId == dataListVM.FactoryId) .Where(globalFilterExpression) .OrderByDescending(x => x.UpdatedDateTime) .Skip((dataListVM.PageNumber - 1) * (dataListVM.PageSize)) .Take(dataListVM.PageSize) .ToListAsync(); var dataRowCount = await _repositoryWrapper.UserAuthInfo.NumOfRecord(); List <UserAuthInfoVM> UserAuthInfoVMLists = new List <UserAuthInfoVM>(); UserAuthInfoVMLists = _utilService.GetMapper().Map <List <UserAuthInfo>, List <UserAuthInfoVM> >(itemCatagoryList); var wrapper = new WrapperUserAuthInfoListVM() { ListOfData = UserAuthInfoVMLists, TotalRecords = dataRowCount }; this._utilService.LogInfo("Successful In Getting Item Category"); return(wrapper); }
public async Task <WrapperUserAuthInfoListVM> Update(string id, UserAuthInfoVM vm) { IEnumerable <UserAuthInfo> ItemDB = await _repositoryWrapper.UserAuthInfo.FindByConditionAsync(x => x.Id == id && x.FactoryId == vm.FactoryId); var ItemUpdated = _utilService.GetMapper().Map <UserAuthInfoVM, UserAuthInfo>(vm, ItemDB.ToList().FirstOrDefault()); _repositoryWrapper.UserAuthInfo.Update(ItemUpdated); await _repositoryWrapper.UserAuthInfo.SaveChangesAsync(); this._utilService.LogInfo("Successful In Updating Item Cateory"); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperUserAuthInfoListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperUserAuthInfoListVM> Add(UserAuthInfoVM vm) { var entityToAdd = _utilService.GetMapper().Map <UserAuthInfoVM, UserAuthInfo>(vm); //string uniqueIdTask =await _repositoryWrapper.UserAuthInfo.GetUniqueId(); //// Todo need to aandle unique id from db //entityToAdd.UniqueId = uniqueIdTask; entityToAdd = _repositoryWrapper.UserAuthInfo.Create(entityToAdd); await _repositoryWrapper.UserAuthInfo.SaveChangesAsync(); this._utilService.LogInfo("Successful In saving Item Category"); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperUserAuthInfoListVM data = await GetListPaged(dataParam); return(data); }