示例#1
0
        /// <summary>
        /// Edits the specified repayment plan.
        /// </summary>
        /// <param name="repaymentPlan">Repayment plan</param>
        /// <param name="shouldSaveChanges">if set to <c>true</c> [should save changes].</param>
        /// <returns>Returns edited repayment plan.</returns>
        /// <exception cref="ArgumentNullException">Repayment plan - repayment plan is not instantiated or Id &lt;= 0</exception>
        public RepaymentPlan Edit(RepaymentPlan repaymentPlan, bool shouldSaveChanges = true)
        {
            // Checks if repayment plan is instantiated
            if (repaymentPlan == null)
            {
                throw new ArgumentNullException(nameof(repaymentPlan), "Repayment plan is not instantiated");
            }

            try
            {
                // Modifies repayment plan
                this.context.Entry(repaymentPlan).State = EntityState.Modified;

                // Saves changes
                if (shouldSaveChanges)
                {
                    this.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(repaymentPlan);
        }
示例#2
0
        /// <summary>
        /// Adds the specified repayment plan.
        /// </summary>
        /// <param name="repaymentPlan">Repayment plan</param>
        /// <param name="shouldSaveChanges">if set to <c>true</c> it will save changes to db.</param>
        /// <returns>Returns newly created repayment plan.</returns>
        public RepaymentPlan Add(RepaymentPlan repaymentPlan, bool shouldSaveChanges = true)
        {
            // Checks if repayment plan is instantiated
            if (repaymentPlan == null)
            {
                throw new ArgumentNullException(nameof(repaymentPlan), "Repayment plan is not instantiated");
            }

            try
            {
                // Adds repayment plan instance to database
                this.context.RepaymentPlan.Add(repaymentPlan);

                // Saves changes
                if (shouldSaveChanges)
                {
                    this.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(repaymentPlan);
        }
        public ActionResult Add(Guid ContractGUID)
        {
            var entity = new RepaymentPlan();

            entity.ContractGUID = ContractGUID;
            return(View("~/views/repaymentplan/form.cshtml", entity));
        }
        public JsonResult Save(RepaymentPlan model)
        {
            var repaymentPlanService = this.GetService <IRepaymentPlanService>();

            if (repaymentPlanService.SaveRepaymentPlan(model) != null)
            {
                ShowMessage("I10010");
            }
            return(Json(null));
        }
        public ActionResult Edit(Guid repaymentPlantGUID)
        {
            var entity = new RepaymentPlan();

            try
            {
                var repaymentPlanService = this.GetService <IRepaymentPlanService>();
                entity = repaymentPlanService.Find <RepaymentPlan>(repaymentPlantGUID);
            }
            catch (CLApplicationException ex)
            {
                //修改时若发生异常则提示异常信息,并关闭修改界面
                this.ShowAppErrorMessage(ex.Message, MessageFuncOption.CloseBrowserWindow);
            }

            return(View("~/views/repaymentplan/form.cshtml", entity));
        }
示例#6
0
        public void SaveRepaymentPlan()
        {
            //插入一条数据
            RepaymentPlan model = new RepaymentPlan();

            service.SaveRepaymentPlan(model);
            service.ServiceContext.Commit();
            Assert.IsTrue(model.RepaymentPlantGUID != null);

            //更新这条数据
            model.RepaymentPlanAmount = 1001;
            service.SaveRepaymentPlan(model);
            service.ServiceContext.Commit();
            Assert.IsTrue(model.RepaymentPlanAmount == 1001);

            //删除这条数据
            service.Delete <ActualPayment>(model.RepaymentPlantGUID);
        }
        /// <summary>
        /// 处理合同回款计划
        /// 根据 id 编号判断是否是添加还是更新,然后调用相应的方法进行处理
        /// </summary>
        /// <param name="model">合同回款计划信息</param>
        /// <returns>处理是否成功</returns>
        public Guid SaveRepaymentPlan(RepaymentPlan model)
        {
            //检查是否存在重复数据
            var entity = this.Find <RepaymentPlan>(model.RepaymentPlantGUID);

            //更新数据 , 否则新增数据
            if (entity != null)
            {
                //更新数据
                entity = Mapper.Map <RepaymentPlan, RepaymentPlan>(model, entity);
                this.repaymentPlanRepository.Update(entity);
            }
            else
            {
                //录入数据
                model.RepaymentPlantGUID = Guid.NewGuid(); //合同基本信息标识
                this.repaymentPlanRepository.Insert(model);
            }

            return(model.RepaymentPlantGUID);
        }
示例#8
0
        public void QueryRepaymentPlan()
        {
            //插入一条数据
            RepaymentPlan model = new RepaymentPlan();

            service.SaveRepaymentPlan(model);
            service.ServiceContext.Commit();
            Assert.IsTrue(model.RepaymentPlantGUID != null);

            //更新这条数据
            model.RepaymentPlanAmount = 1001;
            service.SaveRepaymentPlan(model);
            service.ServiceContext.Commit();
            Assert.IsTrue(model.RepaymentPlanAmount == 1001);

            //设置关键字查询数据
            QueryModel querymodel = new QueryModel();
            int        totalCount = 0;

            querymodel.Key       = model.RepaymentPlantGUID.ToString();
            querymodel.PageIndex = 1;
            querymodel.PageSize  = 10;
            var list = service.QueryRepaymentPlan(querymodel, out totalCount);

            Assert.IsTrue(list.Count() > 0);

            //不设置关键字查询数据
            QueryModel querymodel1 = new QueryModel();
            int        totalCount1 = 0;

            querymodel1.Key       = "";
            querymodel1.PageIndex = 1;
            querymodel1.PageSize  = 10;
            var list1 = service.QueryRepaymentPlan(querymodel, out totalCount1);

            Assert.IsTrue(list1.Count() > 0);

            //删除这条数据
            service.Delete <ActualPayment>(model.RepaymentPlantGUID);
        }