public async Task <WrapperEquipmentCategoryListVM> Delete(EquipmentCategoryVM itemTemp) { IEnumerable <EquipmentCategory> itemTask = await _repositoryWrapper.EquipmentCategory.FindByConditionAsync(x => x.Id == itemTemp.Id && x.FactoryId == itemTemp.FactoryId); var item = itemTask.ToList().FirstOrDefault(); if (item == null) { return(new WrapperEquipmentCategoryListVM()); } _repositoryWrapper.EquipmentCategory.Delete(item); await _repositoryWrapper.EquipmentCategory.SaveChangesAsync(); this._utilService.LogInfo("Successful In Deleting Item Cateory"); var dataParam = new GetDataListVM() { FactoryId = itemTemp.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperEquipmentCategoryListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperEquipmentCategoryListVM> Update(string id, EquipmentCategoryVM vm) { IEnumerable <EquipmentCategory> ItemDB = await _repositoryWrapper.EquipmentCategory.FindByConditionAsync(x => x.Id == id && x.FactoryId == vm.FactoryId); var ItemUpdated = _utilService.GetMapper().Map <EquipmentCategoryVM, EquipmentCategory>(vm, ItemDB.ToList().FirstOrDefault()); _repositoryWrapper.EquipmentCategory.Update(ItemUpdated); await _repositoryWrapper.EquipmentCategory.SaveChangesAsync(); this._utilService.LogInfo("Successful In Updating Item Cateory"); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperEquipmentCategoryListVM data = await GetListPaged(dataParam); return(data); }
public async Task <WrapperEquipmentCategoryListVM> Add(EquipmentCategoryVM vm) { var entityToAdd = _utilService.GetMapper().Map <EquipmentCategoryVM, EquipmentCategory>(vm); //string uniqueIdTask =await _repositoryWrapper.EquipmentCategory.GetUniqueId(); //// Todo need to aandle unique id from db //entityToAdd.UniqueId = uniqueIdTask; entityToAdd = _repositoryWrapper.EquipmentCategory.Create(entityToAdd); await _repositoryWrapper.EquipmentCategory.SaveChangesAsync(); this._utilService.LogInfo("Successful In saving Item Category"); var dataParam = new GetDataListVM() { FactoryId = vm.FactoryId, PageNumber = 1, PageSize = 10, TotalRows = 0 }; WrapperEquipmentCategoryListVM data = await GetListPaged(dataParam); return(data); }
public async Task <ActionResult <WrapperEquipmentCategoryListVM> > DeleteEquipmentCategory([FromBody] EquipmentCategoryVM itemVM) { return(await _serviceWrapper.EquipmentCategoryService.Delete(itemVM)); }
public async Task <ActionResult <WrapperEquipmentCategoryListVM> > AddEquipmentCategory([FromBody] EquipmentCategoryVM EquipmentCategory) { return(await _serviceWrapper.EquipmentCategoryService.Add(EquipmentCategory)); }
public async Task <ActionResult <WrapperEquipmentCategoryListVM> > UpdateEquipmentCategory(string id, [FromBody] EquipmentCategoryVM EquipmentCategory) { return(await _serviceWrapper.EquipmentCategoryService.Update(id, EquipmentCategory)); }