Beispiel #1
0
        public ActionResult Insert(TTransDet viewModel, FormCollection formCollection, bool IsAddStock, string warehouseId)
        {
            //format numeric
            UpdateNumericData(viewModel, formCollection);
            //
            MItem item = _mItemRepository.Get(formCollection["ItemId"]);

            //check stock is enough or not if no add stock
            //return Content(IsAddStock.ToString());
            if (!IsAddStock)
            {
                MWarehouse warehouse    = _mWarehouseRepository.Get(warehouseId);
                bool       isStockValid = Helper.CommonHelper.CheckStock(warehouse, item, viewModel.TransDetQty);
                if (!isStockValid)
                {
                    return(Content("Kuantitas barang tidak cukup"));
                }
            }

            TTransDet transDetToInsert = new TTransDet();

            TransferFormValuesTo(transDetToInsert, viewModel);
            transDetToInsert.SetAssignedIdTo(Guid.NewGuid().ToString());
            transDetToInsert.ItemId = item;
            transDetToInsert.SetAssignedIdTo(viewModel.Id);
            transDetToInsert.CreatedDate = DateTime.Now;
            transDetToInsert.CreatedBy   = User.Identity.Name;
            transDetToInsert.DataStatus  = EnumDataStatus.New.ToString();

            ListDetTrans.Add(transDetToInsert);
            return(Content("success"));
        }
Beispiel #2
0
        public ActionResult Delete(TTransDet viewModel, FormCollection formCollection)
        {
            //remove use native predicate function from list, awesome, no need foreach anymore
            ListDetTrans.Remove(ListDetTrans.Find(ByTransDetId(viewModel.Id)));


            if (ListDeleteDetailTrans == null)
            {
                ListDeleteDetailTrans = new ArrayList();
            }
            ListDeleteDetailTrans.Add(viewModel.Id);
            return(Content("success"));
        }
Beispiel #3
0
        public ActionResult Update(TTransDet viewModel, FormCollection formCollection)
        {
            TTransDet transDetToInsert = new TTransDet();

            TransferFormValuesTo(transDetToInsert, viewModel);
            transDetToInsert.SetAssignedIdTo(viewModel.Id);
            transDetToInsert.CreatedDate = DateTime.Now;
            transDetToInsert.CreatedBy   = User.Identity.Name;
            transDetToInsert.DataStatus  = EnumDataStatus.New.ToString();

            ListDetTrans.Add(transDetToInsert);
            return(Content("success"));
        }
Beispiel #4
0
 public ActionResult Delete(TTransDet viewModel, FormCollection formCollection)
 {
     ListDetTrans.Remove(viewModel);
     return(Content("success"));
 }