コード例 #1
0
        public ActionResult Create(StartingBalanceViewModel startingBalance)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here
                    var user = _userProfileService.GetUser(User.Identity.Name);
                    _transactionService.SaveStartingBalanceTransaction(startingBalance, user);
                    return Json(true, JsonRequestBehavior.AllowGet);

                }
                return View();
            }
            catch
            {
                return View();
            }
        }
コード例 #2
0
        //
        // GET: /StartingBalance/Create
        public ActionResult Create()
        {
            List<Commodity> Commodities;
            List<Program> Programs;
            List<Store> Stores;
            List<Unit> Units;
            List<Donor> Donors;

            var user = _userProfileService.GetUser(User.Identity.Name);

            Commodities = _commodityService.GetAllCommodity().Where(c=>c.ParentID != null).ToList();
            Programs = _programService.GetAllProgram().ToList();
            Stores =_storeService.GetAllStore().Where(h=>h.HubID == user.DefaultHub.HubID).ToList();
            Units = _unitService.GetAllUnit().ToList();
            Donors = _donorSerivce.GetAllDonor().ToList();

            StartingBalanceViewModel startingBalanceViewModel = new StartingBalanceViewModel(Commodities,Stores,Units,Programs,Donors, user);
            return PartialView(startingBalanceViewModel);
        }
コード例 #3
0
ファイル: TransactionService.cs プロジェクト: FishAbe/cats
        /// <summary>
        /// Saves the starting balance transaction.
        /// </summary>
        /// <param name="startingBalance">The starting balance.</param>
        /// <param name="user">The user.</param>
        /// <exception cref="System.Exception"></exception>
        public void SaveStartingBalanceTransaction(StartingBalanceViewModel startingBalance, UserProfile user)
        {
            int repositoryAccountGetAccountIDWithCreateNegative = _accountService.GetAccountIdWithCreate(Account.Constants.DONOR, startingBalance.DonorID); ;

            int repositoryProjectCodeGetProjectCodeIdWIthCreateProjectCodeID = _projectCodeService.GetProjectCodeIdWIthCreate(startingBalance.ProjectNumber).ProjectCodeID; ;
            int repositoryShippingInstructionGetSINumberIdWithCreateShippingInstructionID = _shippingInstructionService.GetSINumberIdWithCreate(startingBalance.SINumber).ShippingInstructionID; ;
            int repositoryAccountGetAccountIDWithCreatePosetive = _accountService.GetAccountIdWithCreate(Account.Constants.HUB, user.DefaultHub.Value); ;

            TransactionGroup transactionGroup = new TransactionGroup();

            Transaction transactionOne = new Transaction();

            var transactionGroupId = Guid.NewGuid();

            transactionOne.TransactionID = Guid.NewGuid();
            transactionOne.TransactionGroupID = transactionGroupId;
            transactionOne.PartitionId = 0;
            transactionOne.LedgerID = Cats.Models.Ledger.Constants.GOODS_UNDER_CARE;
            transactionOne.HubOwnerID = user.DefaultHubObj.HubOwner.HubOwnerID;
            transactionOne.AccountID = repositoryAccountGetAccountIDWithCreateNegative;
            transactionOne.HubID = user.DefaultHub.Value;
            transactionOne.StoreID = startingBalance.StoreID;
            transactionOne.Stack = startingBalance.StackNumber;
            transactionOne.ProjectCodeID = repositoryProjectCodeGetProjectCodeIdWIthCreateProjectCodeID;
            transactionOne.ShippingInstructionID = repositoryShippingInstructionGetSINumberIdWithCreateShippingInstructionID;
            transactionOne.ProgramID = startingBalance.ProgramID;
            var comm = _unitOfWork.CommodityRepository.FindById(startingBalance.CommodityID);

            transactionOne.CommodityID = (comm.ParentID != null)
                                                      ? comm.ParentID.Value
                                                      : comm.CommodityID;

            //transactionOne.ParentCommodityID = (comm.ParentID != null)
            //                                           ? comm.ParentID.Value
            //                                           : comm.CommodityID;
            transactionOne.CommodityChildID = startingBalance.CommodityID;
            transactionOne.CommodityGradeID = null;
            transactionOne.QuantityInMT = 0 - startingBalance.QuantityInMT;
            transactionOne.QuantityInUnit = 0 - startingBalance.QuantityInUnit;
            transactionOne.UnitID = startingBalance.UnitID;
            transactionOne.TransactionDate = DateTime.Now;

            Transaction transactionTwo = new Transaction();

            transactionTwo.TransactionID = Guid.NewGuid();
            transactionTwo.TransactionGroupID = transactionGroupId;
            transactionTwo.PartitionId = 0;
            transactionTwo.LedgerID = Cats.Models.Ledger.Constants.GOODS_ON_HAND;
            transactionTwo.HubOwnerID = user.DefaultHubObj.HubOwnerID;
            transactionTwo.AccountID = repositoryAccountGetAccountIDWithCreatePosetive;
            transactionTwo.HubID = user.DefaultHub.Value;
            transactionTwo.StoreID = startingBalance.StoreID;
            transactionTwo.Stack = startingBalance.StackNumber;
            transactionTwo.ProjectCodeID = repositoryProjectCodeGetProjectCodeIdWIthCreateProjectCodeID;
            transactionTwo.ShippingInstructionID = repositoryShippingInstructionGetSINumberIdWithCreateShippingInstructionID;
            transactionTwo.ProgramID = startingBalance.ProgramID;

            transactionTwo.CommodityID = (comm.ParentID != null)
                                                      ? comm.ParentID.Value
                                                      : comm.CommodityID;

            //transactionTwo.ParentCommodityID = (comm.ParentID != null)
            //                                           ? comm.ParentID.Value
            //                                           : comm.CommodityID;
            transactionTwo.CommodityChildID = startingBalance.CommodityID;
            transactionTwo.CommodityGradeID = null; // How did I get this value ?
            transactionTwo.QuantityInMT = startingBalance.QuantityInMT;
            transactionTwo.QuantityInUnit = startingBalance.QuantityInUnit;
            transactionTwo.UnitID = startingBalance.UnitID;
            transactionTwo.TransactionDate = DateTime.Now;

            transactionGroup.PartitionId = 0;

            try
            {
                transactionGroup.TransactionGroupID = transactionGroupId;
                transactionGroup.Transactions.Add(transactionOne);
                transactionGroup.Transactions.Add(transactionTwo);
                _unitOfWork.TransactionGroupRepository.Add(transactionGroup);
                _unitOfWork.Save();

            }
            catch (Exception exp)
            {

                //TODO: Save the detail of this exception somewhere
                throw new Exception("The Starting Balance Transaction Cannot be saved. <br />Detail Message :" + exp.Message);
            }
        }
コード例 #4
0
        public ActionResult Edit(StartingBalanceViewModel startingBalance)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
コード例 #5
0
        public ActionResult Delete(int id, StartingBalanceViewModel startingBalance)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }