public async Task <WrapperExpenseTypeListVM> Delete(ExpenseTypeVM itemTemp)
        {
            IEnumerable <ExpenseType> itemTask = await _repositoryWrapper.ExpenseType.FindByConditionAsync(x => x.Id == itemTemp.Id && x.FactoryId == itemTemp.FactoryId);

            var item = itemTask.ToList().FirstOrDefault();

            if (item == null)
            {
                return(new WrapperExpenseTypeListVM());
            }
            _repositoryWrapper.ExpenseType.Delete(item);
            await _repositoryWrapper.ExpenseType.SaveChangesAsync();

            this._utilService.LogInfo("Successful In Deleting Item Cateory");

            var dataParam = new GetDataListVM()
            {
                FactoryId  = itemTemp.FactoryId,
                PageNumber = 1,
                PageSize   = 10,
                TotalRows  = 0
            };
            WrapperExpenseTypeListVM data = await GetListPaged(dataParam);

            return(data);
        }
예제 #2
0
 public void save(ExpenseTypeVM vm)
 {
     try
     {
         ExpenseTypeTbl entity = new ExpenseTypeTbl();
         entity.Type = vm.Type;
         _MarbalContext.Entry(entity).State = EntityState.Added;
         _MarbalContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
 public IActionResult DoAdd(ExpenseTypeVM model)
 {
     if (ModelState.IsValid)
     {
         _expensesService.AddExpenseType(Mapper.Map <ExpenseTypeSM>(model));
         if (_expensesService.BusinessStateValid)
         {
             SetControllerMessage(ControllerMessageType.Success, "Added");
             return(RedirectToAction("Index"));
         }
         model.SetErrorMessage(_expensesService.BusinessErrors, Language);
     }
     return(View("Add", model));
 }
        public async Task <WrapperExpenseTypeListVM> Update(string id, ExpenseTypeVM vm)
        {
            IEnumerable <ExpenseType> ItemDB = await _repositoryWrapper.ExpenseType.FindByConditionAsync(x => x.Id == id && x.FactoryId == vm.FactoryId);

            var ItemUpdated = _utilService.GetMapper().Map <ExpenseTypeVM, ExpenseType>(vm, ItemDB.ToList().FirstOrDefault());

            _repositoryWrapper.ExpenseType.Update(ItemUpdated);
            await _repositoryWrapper.ExpenseType.SaveChangesAsync();

            this._utilService.LogInfo("Successful In Updating Item Cateory");


            var dataParam = new GetDataListVM()
            {
                FactoryId  = vm.FactoryId,
                PageNumber = 1,
                PageSize   = 10,
                TotalRows  = 0
            };
            WrapperExpenseTypeListVM data = await GetListPaged(dataParam);

            return(data);
        }
        public async Task <WrapperExpenseTypeListVM> Add(ExpenseTypeVM vm)
        {
            var entityToAdd = _utilService.GetMapper().Map <ExpenseTypeVM, ExpenseType>(vm);

            //string uniqueIdTask =await _repositoryWrapper.ExpenseType.GetUniqueId();

            //// Todo  need to aandle unique id from db
            //entityToAdd.UniqueId = uniqueIdTask;
            entityToAdd = _repositoryWrapper.ExpenseType.Create(entityToAdd);
            await _repositoryWrapper.ExpenseType.SaveChangesAsync();

            this._utilService.LogInfo("Successful In saving  Item Category");

            var dataParam = new GetDataListVM()
            {
                FactoryId  = vm.FactoryId,
                PageNumber = 1,
                PageSize   = 10,
                TotalRows  = 0
            };
            WrapperExpenseTypeListVM data = await GetListPaged(dataParam);

            return(data);
        }
예제 #6
0
        public ActionResult Create(ExpenseTypeVM vm)
        {
            try
            {
                _expenseTypeRepository.save(vm);
                Response.StatusCode = 200;
                return(Json(new
                {
                    param1 = vm.Type,
                    param2 = _MESSAGES.SUCCESS
                }));
            }
            catch (Exception ex)
            {
                Response.StatusCode = 404;
                return(Json(new
                {
                    param1 = 0,
                    param2 = _MESSAGES.ERROR
                }));

                throw ex;
            }
        }
 public async Task <ActionResult <WrapperExpenseTypeListVM> > DeleteExpenseType([FromBody] ExpenseTypeVM itemVM)
 {
     return(await _serviceWrapper.ExpenseTypeService.Delete(itemVM));
 }
 public async Task <ActionResult <WrapperExpenseTypeListVM> > AddExpenseType([FromBody] ExpenseTypeVM ExpenseType)
 {
     return(await _serviceWrapper.ExpenseTypeService.Add(ExpenseType));
 }
 public async Task <ActionResult <WrapperExpenseTypeListVM> > UpdateExpenseType(string id, [FromBody] ExpenseTypeVM ExpenseType)
 {
     return(await _serviceWrapper.ExpenseTypeService.Update(id, ExpenseType));
 }