示例#1
0
 public bool UpdateAgreement(AgreementModel agreement)
 {
     _context.Entry(GetAgreement(agreement.CNPCUI)).State = EntityState.Detached;
     _context.Entry(agreement).State = EntityState.Modified;
     _context.Update(agreement);
     return(Save());
 }
示例#2
0
        public static List <AgreementModel> GetAgreement(Action <CommandFilter> match)
        {
            var command = _dbBaseProvider.CreateCommandStruct("AgreementClass", CommandMode.Inquiry);

            command.Columns = string.Format("AgreementID,GameID,Title,Describe,CreateDate,(SELECT SLNNAME FROM SOLUTIONS WHERE SLNID={0}.GAMEID) SlnName", command.TableName);
            command.OrderBy = "AgreementID ASC";
            command.Filter  = _dbBaseProvider.CreateCommandFilter();
            if (match != null)
            {
                match(command.Filter);
            }
            command.Parser();
            var list = new List <AgreementModel>();

            using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
            {
                while (reader.Read())
                {
                    AgreementModel model = new AgreementModel();
                    model.AgreementID = reader["AgreementID"].ToInt();
                    model.GameID      = reader["GameID"].ToInt();
                    model.Title       = reader["Title"].ToNotNullString();
                    model.Describe    = reader["Describe"].ToNotNullString();
                    model.CreateDate  = reader["CreateDate"].ToDateTime();
                    model.SlnName     = reader["SlnName"].ToNotNullString();

                    list.Add(model);
                }
            }
            return(list);
        }
示例#3
0
        public async Task <ResultModel> GetCustomerDataAsync(AgreementModel agreementModel)
        {
            _log.LogInformation("Starting interest rate data gathering and calculations");

            var customer = await _personService.GetCustomersByIdAsync(agreementModel.CustomerId);

            if (customer == null)
            {
                _log.LogError($"No Customer found with id: {agreementModel.CustomerId}");
                return(null);
            }

            ResultModel result = new ResultModel();

            result.Customer = customer;
            result.InterestRates.NewInterestRate = await CalculateNewInterestRate(agreementModel.BaseRateCode, agreementModel.Margin);

            var latestAgreement = customer.Agreements?.OrderByDescending(x => x.Timestamp).FirstOrDefault();

            if (latestAgreement != null)
            {
                result.InterestRates.CurrentInterestRate = await GetCurrentInterestRate(latestAgreement);

                result.InterestRates.InterestRateDifference = CalculateRateDifference(result.InterestRates.CurrentInterestRate, result.InterestRates.NewInterestRate);
            }

            result.Agreement = await SaveNewAgreementAsync(agreementModel);

            return(result);
        }
        public string UpdateAgreementStatus([FromBody] AgreementModel agreement)
        {
            string str = "Thanks!";

            try
            {
                DBManager.VerifyAgreement(agreement.Agreement_Id, callback =>
                {
                    if (callback != null)
                    {
                        DBManager.UpdateAgreement(agreement);
                        proxy = new HttpProxyServer();
                        if (callback.enableCallback.Equals("true"))
                        {
                            proxy.PostAgreement(callback, agreement);
                        }
                    }
                    else
                    {
                        str = "Invalid agreement !";
                    }
                });
            }
            catch (Exception eexx)
            {
                str = "Exception in UpdateAgreement  " + eexx;
            }

            return(str);
        }
示例#5
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                int    id       = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
                string Title    = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Title")).Text;
                string Describe = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Describe")).Text;


                AgreementModel mode = new AgreementModel();
                mode.AgreementID = id;
                mode.Title       = Title;
                mode.Describe    = Describe;

                if (DbDataLoader.Update(mode))
                {
                    GridView1.EditIndex = -1;
                    BindData();
                }
            }

            catch (Exception erro)
            {
                Response.Write("错误信息:" + erro.Message);
            }
        }
示例#6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(AgreementModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AgreementClass(");
            strSql.Append("GameID,Title,Describe)");
            strSql.Append(" values (");
            strSql.Append("@GameID,@Title,@Describe)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GameID",   SqlDbType.Int,     4),
                new SqlParameter("@Title",    SqlDbType.VarChar, 0),
                new SqlParameter("@Describe", SqlDbType.VarChar, 0)
            };
            parameters[0].Value = model.GameID;
            parameters[1].Value = model.Title;
            parameters[2].Value = model.Describe;

            object obj = SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        public string CreateAgreement([FromBody] AgreementModel agreement)
        {
            int    id = 0; string str = "Thanks!";
            string query = "select ID from MobilePayOnBoarding where BCTenantId='" + agreement.BcTenantId + "'";

            try
            {
                DBManager.VerifyTenantID(query, status =>
                {
                    if (status.Equals("S"))
                    {
                        id = DBManager.InsertAgreement(agreement);
                    }

                    if (id == 0)
                    {
                        str = "ERROR on creating agreement!";
                    }

                    if (id == -1)
                    {
                        str = "Agreement Id already Exist !";
                    }
                });
            }
            catch (Exception eexx)
            {
                str = "Exception in Create Agreement " + eexx;
            }

            return(str);
        }
        public void PostAgreement(BCClientModel clientModel, AgreementModel agreement)
        {
            string         Cred            = clientModel.userName + ":" + clientModel.password;
            HttpWebRequest request         = Common.CreateWebRequest(clientModel.BCTenantId, Cred, null);
            XmlDocument    soapEnvelopeXml = new XmlDocument();

            soapEnvelopeXml.LoadXml(@"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:mer='urn:microsoft-dynamics-schemas/codeunit/MerchantTokens'> <soapenv:Body> <mer:AgreementStatus> <mer:agreementId>" + agreement.Agreement_Id + "</mer:agreementId> <mer:status>" + agreement.Status + "</mer:status> <mer:statusText>" + agreement.Status_Text + "</mer:statusText> <mer:statusCode>" + agreement.Status_Code + "</mer:statusCode> <mer:callBackTime>" + agreement.Timestamp + "</mer:callBackTime> </mer:AgreementStatus> </soapenv:Body> </soapenv:Envelope>");

            using (Stream stream = request.GetRequestStream())
            {
                soapEnvelopeXml.Save(stream);
            }
            try
            {
                using (WebResponse response = request.GetResponse())
                {
                    using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                    {
                        string soapResult = rd.ReadToEnd();
                        Console.WriteLine(soapResult);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AgreementModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AgreementClass set ");
            strSql.Append("Title=@Title,Describe=@Describe");
            strSql.Append(" where AgreementID=@AgreementID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",    SqlDbType.VarChar, 0),
                new SqlParameter("@Describe", SqlDbType.VarChar, 0),new SqlParameter("@AgreementID",  SqlDbType.VarChar, 0)
            };

            parameters[0].Value = model.Title;
            parameters[1].Value = model.Describe;
            parameters[2].Value = model.AgreementID;
            int rows = SqlHelper.ExecuteNonQuery(connectionString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#10
0
 public static void UpdateAgreement(AgreementModel agreement)
 {
     WithConnection(conn =>
     {
         UpdateAgreement(agreement, conn);
     });
 }
示例#11
0
        public AgreementModel GetManagementModel(AgreementInfo.AgreementTypes type)
        {
            AgreementModel agreementModel = new AgreementModel();
            AgreementInfo  agreement      = this._iSystemAgreementService.GetAgreement(type);

            agreementModel.AgreementType    = agreement.AgreementType;
            agreementModel.AgreementContent = agreement.AgreementContent;
            return(agreementModel);
        }
示例#12
0
        public byte[] Generate(string fullName, DateTime date)
        {
            var template = GetTemplate();
            var model    = new AgreementModel {
                FullName = fullName, CurrentDate = date
            };

            return(_agreementRenderer.RenderAgreementToPdf(template, model));
        }
示例#13
0
        public AgreementModel GetManagementModel(Himall.Model.AgreementInfo.AgreementTypes type)
        {
            AgreementModel model      = new AgreementModel();
            var            iAgreement = _iSystemAgreementService.GetAgreement(type);

            model.AgreementType    = iAgreement.AgreementType;
            model.AgreementContent = iAgreement.AgreementContent;
            return(model);
        }
示例#14
0
        public AgreementModel GetManagementModel(AgreementInfo.AgreementTypes type)
        {
            AgreementModel agreementModel = new AgreementModel();
            AgreementInfo  agreement      = ServiceHelper.Create <ISystemAgreementService>().GetAgreement(type);

            agreementModel.AgreementType    = agreement.AgreementType;
            agreementModel.AgreementContent = agreement.AgreementContent;
            return(agreementModel);
        }
示例#15
0
        private static void UpdateAgreement(AgreementModel agreement, SqlConnection conn)
        {
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
            var            query          = "Update UserAgreement Set status='" + agreement.Status + "', StatusText= '" + agreement.Status_Text + "', StatusCode= '" + agreement.Status_Code + "', ExternalId= '" + agreement.External_Id + "' ,TimesStamp='" + agreement.Timestamp + "' where AgreementId='" + agreement.Agreement_Id + "'";
            SqlCommand     sqlCommand     = new SqlCommand(query, conn);

            sqlDataAdapter.InsertCommand = new SqlCommand(query, conn);
            sqlDataAdapter.InsertCommand.ExecuteNonQuery();
            sqlCommand.Dispose();
        }
示例#16
0
        public static bool Delete(AgreementModel model)
        {
            var command = _dbBaseProvider.CreateCommandStruct("AgreementClass", CommandMode.Delete);

            command.Filter           = _dbBaseProvider.CreateCommandFilter();
            command.Filter.Condition = _dbBaseProvider.FormatFilterParam("AgreementID");
            command.Filter.AddParam("AgreementID", model.AgreementID);
            command.Parser();
            return(_dbBaseProvider.ExecuteQuery(CommandType.Text, command.Sql, command.Parameters) > 0);
        }
示例#17
0
        public static int InsertAgreement(AgreementModel agreement)
        {
            int x = 0;

            WithConnection(conn =>
            {
                x = InsertAgreement(agreement, conn);
            });
            return(x);
        }
示例#18
0
        private async Task <decimal?> GetCurrentInterestRate(AgreementModel latestAgreement)
        {
            var baseRate = await _baseRateService.GetBaseRateByCodeAsync(latestAgreement.BaseRateCode);

            if (baseRate.HasValue)
            {
                return(baseRate.Value + latestAgreement.Margin);
            }

            return(null);
        }
示例#19
0
        public string RenderAgreement(Customer customer)
        {
            var agreement = _repository.GetByCustomerId(customer.Id);
            var template  = agreement == null?GetTemplate() : agreement.Template;

            var model = new AgreementModel {
                FullName = customer.PersonalInfo.Fullname, CurrentDate = customer.GreetingMailSentDate ?? DateTime.UtcNow
            };

            return(_agreementRenderer.RenderAgreement(template, model));
        }
示例#20
0
        public AgreementModel GetManagementModel(Entities.AgreementInfo.AgreementTypes type)
        {
            AgreementModel model      = new AgreementModel();
            var            iAgreement = SystemAgreementApplication.GetAgreement(type);

            if (iAgreement != null)
            {
                model.AgreementType    = iAgreement.AgreementType;
                model.AgreementContent = iAgreement.AgreementContent;
            }
            return(model);
        }
示例#21
0
        private static int InsertAgreement(AgreementModel agreement, SqlConnection conn)
        {
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
            var            query          = "if exists(select 1 from UserAgreement   where  [AgreementId] = '" + agreement.Agreement_Id + "' ) Begin Select -1 End Else Begin insert into UserAgreement (AgreementId,BCTenantId) OUTPUT INSERTED.ID values('" + agreement.Agreement_Id + "','" + agreement.BcTenantId + "') End;";
            SqlCommand     sqlCommand     = new SqlCommand(query, conn);

            sqlDataAdapter.InsertCommand = new SqlCommand(query, conn);
            var val = sqlDataAdapter.InsertCommand.ExecuteScalar();

            sqlCommand.Dispose();
            return((Int32)val);
        }
示例#22
0
        public Result <AgreementModel> PutAgreementModel(AgreementModel agreementModel)
        {
            var validateResult = _validatorService.ValidateAgreement(agreementModel);

            if (validateResult.ResultType != ResultType.Ok)
            {
                Result <AgreementModel> result = new BadRequestResult <AgreementModel>(validateResult.Errors);
                if (_errorService.AddError(
                        (agreementModel.CNPCUI != null ? agreementModel.CNPCUI : "invalid"),
                        result.ResultType,
                        result.Errors,
                        "Put") == false)
                {
                    Console.WriteLine("Error service failed");
                }
                return(result);
            }

            try
            {
                if (!_agreementRepository.AgreementExists(agreementModel.CNPCUI))
                {
                    Result <AgreementModel> result = new NotFoundResult <AgreementModel>("Agreement not found!");
                    if (_errorService.AddError(agreementModel.CNPCUI, result.ResultType, result.Errors, "Put") == false)
                    {
                        Console.WriteLine("Error service failed");
                    }
                    return(result);
                }
                bool success = _agreementRepository.UpdateAgreement(agreementModel);

                if (!success)
                {
                    Result <AgreementModel> result = new BadRequestResult <AgreementModel>("Bad request: Agreement update failed!");
                    if (_errorService.AddError(agreementModel.CNPCUI, result.ResultType, result.Errors, "Put") == false)
                    {
                        Console.WriteLine("Error service failed");
                    }
                    return(result);
                }
            }
            catch
            {
                Result <AgreementModel> result = new UnexpectedResult <AgreementModel>();
                if (_errorService.AddError(agreementModel.CNPCUI, result.ResultType, result.Errors, "Put") == false)
                {
                    Console.WriteLine("Error service failed");
                }
                return(result);
            }
            return(new SuccessResult <AgreementModel>(agreementModel));
        }
示例#23
0
        public AgreementModel GetManagementModel(Himall.Model.AgreementInfo.AgreementTypes type)
        {
            AgreementModel model = new AgreementModel();

            model.AgreementType = (int)type;
            var agreement = SystemAgreementApplication.GetAgreement(type);

            if (agreement != null)
            {
                model.AgreementContent = agreement.AgreementContent;
            }
            return(model);
        }
示例#24
0
        public ActionResult Download()
        {
            AgreementRenderer agreementRenderer = new AgreementRenderer();

            string template = (string)Session["Template"];

            JavaScriptSerializer jss   = new JavaScriptSerializer();
            AgreementModel       model = jss.Deserialize <AgreementModel>(GetDummyAgreementModel());

            var pdf = agreementRenderer.RenderAgreementToPdf(template, model);

            return(File(pdf, "application/pdf", "test" + " Summary_" + DateTime.Now + ".pdf"));
        } // Download
示例#25
0
        public async Task <AgreementModel> SaveNewAgreementAsync(AgreementModel agreement)
        {
            var mappedNewAgreement = _mapper.Map <Agreement>(agreement);

            if (mappedNewAgreement != null)
            {
                var savedAgreement = await _agreementRepository.SaveNewAgreementAsync(mappedNewAgreement);

                return(_mapper.Map <AgreementModel>(savedAgreement));
            }

            return(null);
        }
示例#26
0
		} // CreateSchedule

		public void CalculateTotal(decimal fee, List<LoanScheduleItem> schedule, AgreementModel model) {
			model.TotalAmount = FormattingUtils.NumericFormats(schedule.Sum(a => a.AmountDue));
			model.TotalPrincipal = FormattingUtils.NumericFormats(schedule.Sum(a => a.LoanRepayment));
			model.TotalInterest = FormattingUtils.NumericFormats(schedule.Sum(a => a.Interest));
			model.TotalAmoutOfCredit = FormattingUtils.NumericFormats(schedule.Sum(a => a.LoanRepayment));
			model.TotalFees = FormattingUtils.NumericFormats(fee);

			//var currencyRateRepository = ObjectFactory.GetInstance<CurrencyRateRepository>();
			//decimal currencyRate = (decimal)currencyRateRepository.GetCurrencyHistoricalRate(DateTime.UtcNow, "USD");
			decimal currencyRate = GetUSDCurrencyRate();
			model.TotalPrincipalUsd = "$ " + (CurrentValues.Instance.AlibabaCurrencyConversionCoefficient * currencyRate *
									   schedule.Sum(a => a.LoanRepayment)).ToString("N", CultureInfo.CreateSpecificCulture("en-gb"));
		} // CalculateTotal
示例#27
0
        public ActionResult CreateAgreement(AgreementModel model)
        {
            ServiceModelsAgreementDTO agreement = new ServiceModelsAgreementDTO
            {
                PersonaId = model.PersonalId,
                Amount    = model.Amount,
                Margin    = model.Margin,
                Duration  = model.Duration,
                Code      = model.BaseRateCode.ToString()
            };

            if (service.CreateAgreement(agreement) == 0)
            {
                return(View("Error"));
            }
            return(View("SuccessfulSubmit"));
        }
        public ActionResult <AgreementModel> Post(AgreementModel agreementModel)
        {
            Result <AgreementModel> result = _businessService.PostAgreementModel(agreementModel);

            switch (result.ResultType)
            {
            case ResultType.Unexpected:
                return(StatusCode(500, result.Errors));

            case ResultType.BadRequest:
                return(BadRequest(result.Errors));

            default:
                break;
            }
            return(result.Data);
        }
示例#29
0
        public static int Add(AgreementModel model)
        {
            var command = _dbBaseProvider.CreateCommandStruct("AgreementClass", CommandMode.Insert);

            command.AddParameter("GameID", model.GameID);
            command.AddParameter("Title", model.Title);
            command.AddParameter("Describe", model.Describe);
            command.ReturnIdentity = true;
            command.Parser();
            using (var reader = _dbBaseProvider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
            {
                if (reader.Read())
                {
                    model.AgreementID = reader[0].ToInt();
                }
            }
            return(model.AgreementID);
        }
示例#30
0
 public SaveAgreement(
     int customerId,
     AgreementModel model,
     string refNumber,
     string name,
     TemplateModel template,
     string path1,
     string path2
     )
 {
     _name       = name;
     _template   = template;
     _path1      = path1;
     _path2      = path2;
     _customerId = customerId;
     _model      = model;
     _refNumber  = refNumber;
 }         // constructor