public ActionResult Create(Contract model) { model.ActionOperationType = EActionOperationType.Create; if (ModelState.IsValid) { ContractService service = new ContractService(); service.Add(model); return RedirectToAction("Index"); } this.LoadEditViewBag(model); return View("Create",model); }
//收藏功能 protected void collect() { int uid = ((User)Session["userInfo"]).uid; contractList = contractService.GetModelList("uid='" + uid + "' and hid='" + hid + "' and cstatus= '" + contractService.collectstatus + "'"); //不存在则执行添加方法,已存在则取消收藏执行删除方法 if (contractList.Count == 0) { Contract contract = new Contract(); contract.hid = hid; contract.uid = uid; contract.cstatus = contractService.collectstatus; if (contractService.Add(contract) > 0) { Response.Write(true); Response.End(); } else { Response.Write(false); Response.End(); } } else { int cid = contractList[0].cid; if (contractService.Delete(cid)) { Response.Write(false); Response.End(); } else { Response.Write(true); Response.End(); } } }
public dynamic Post([FromRoute] string enrollmentNumber, [FromBody] Form obj) { Enrollment enrollment = _enrollmentService.List().SingleOrDefault(x => x.ExternalId == enrollmentNumber); if (enrollment == null) { return(new BadRequestObjectResult(new { messages = new List <string> { onboarding.Resources.Messages.EnrollmentLinkIsNotValid } })); } if (!enrollment.IsDeadlineValid()) { return(new BadRequestObjectResult(new { messages = new List <string> { onboarding.Resources.Messages.OnboardingExpired } })); } Contract contract = _mapper.Map <Contract>(obj); if (enrollment.Contract != null) { enrollment.Contract.Signature = contract.Signature; enrollment.Contract.AcceptedAt = contract.AcceptedAt; contract = _contractService.Update(enrollment.Contract); } else { contract = _contractService.Add(contract); } ContractValidator validator = new ContractValidator(); Hashtable errors = FormatErrors(validator.Validate(contract)); ContractStatus contractStatus = new ContractStatus(validator, contract); if (contractStatus.GetStatus() == "valid") { _enrollmentStepService.Update(enrollmentNumber, "Contracts"); } return(new OkObjectResult(new { errors, data = _mapper.Map <Record>(contract) })); }
public void Add_ContractObjectPassed_ShouldResultGetId() { // Arrange var newContract = new ContractModel() { BrokerAgentName = "BrokerAgentName", BrokerCompanyName = "BrokerCompanyName", CustomerName = "CustomerName", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(1), }; // Act var repository = new ContractService(mockIContractDatabaseSettings.Object, mapperFixture.mockMapper); var result = repository.Add(newContract); //Assert Assert.False(string.IsNullOrEmpty(result.Id)); }
protected void btnSave_Click(object sender, EventArgs e) { try { Validate("AddEdit"); if (IsValid) { if (calDateOfBirth.SelectedDate > DateTime.Today) { DynamicControlBinding.SetLabelTextWithCssClass( lblMessageAddEdit, "Invalid date of birth", LabelStyleNames.ErrorMessage); return; } if (ddlBillingType.SelectedItem.Text.ToUpper() == "AUTO PAYMENT") { cuvCreditCardNo.Validate(); if (cuvCreditCardNo.IsValid) { if (ddlBillingCardType.SelectedIndex == 0 || ddlBillingBank.SelectedIndex == 0 || String.IsNullOrEmpty(txtBillingCardHolderID.Text) || String.IsNullOrEmpty(txtBillingCardHolderName.Text) || String.IsNullOrEmpty(txtBillingCardNo.Text)) { DynamicControlBinding.SetLabelTextWithCssClass( lblMessageAddEdit, "Auto payment information is incomplete", LabelStyleNames.ErrorMessage); return; } } if (txtDuesAmount.Text.ToDefaultNumber <decimal>() == 0 || ddlMonthlyDuesItem.SelectedValue.ToDefaultNumber <int>() == 0) { DynamicControlBinding.SetLabelTextWithCssClass( lblMessageAddEdit, "Both <b>Dues Amount</b> and <b>Monthly Dues Item</b> fields must be specified if billing type is manual payment", LabelStyleNames.ErrorMessage); return; } } if (chkGenerateNewBarcodeCustomer.Checked) { if (chkFather.Checked && ( String.IsNullOrEmpty(txtFatherName.Text))) { DynamicControlBinding.SetLabelTextWithCssClass( lblStatusParent, "Parent Information (Father) is incomplete", cssClass: LabelStyleNames.ErrorMessage); return; } if (chkMother.Checked && ( String.IsNullOrEmpty(txtMotherName.Text))) { DynamicControlBinding.SetLabelTextWithCssClass( lblStatusParent, "Parent Information (Mother) is incomplete", LabelStyleNames.ErrorMessage); return; } } switch (RowID) { case 0: ContractService.Add( calDate.SelectedDate.GetValueOrDefault(), !chkGenerateNewBarcodeCustomer.Checked, txtCustomerBarcode.Text, chkIsTransfer.Checked, txtCustomerFirstName.Text, txtCustomerLastName.Text, calDateOfBirth.SelectedDate.GetValueOrDefault(), txtIDCardNo.Text, ddlOccupation.SelectedIndex == 0 ? (int?)null :Convert.ToInt32(ddlOccupation.SelectedValue), Convert.ToInt32(ddlFindBranch.SelectedValue), Convert.ToInt32(ddlPackage.SelectedValue), null, calEffectiveDate.SelectedDate.GetValueOrDefault(), Convert.ToInt32(ddlBillingType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingCardType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingBank.SelectedValue), txtBillingCardNo.Text, txtBillingCardHolderName.Text, txtBillingCardHolderID.Text, new DateTime(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue), DateTime.DaysInMonth(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue))), 'P', Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlMonthlyDuesItem.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtDuesAmount.Value), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtAdditionalDuesAmount.Value), calNextDuesDate.SelectedDate.GetValueOrDefault(), calExpiredDate.SelectedDate.GetValueOrDefault(), txtHomePhone.Text, txtCellPhone.Text, txtWorkPhone.Text, txtMailingAddress.Text, txtMailingZipCode.Text, txtAddress.Text, txtZipCode.Text, Convert.ToInt32(ddlArea.SelectedValue), chkFather.Checked, txtFatherName.Text, txtIDCardNoFather.Text, chkFatherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateFather.SelectedDate, txtFatherPhone.Text, txtFatherEmail.Text, chkMother.Checked, txtMotherName.Text, txtIDCardNoMother.Text, chkMotherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateMother.SelectedDate, txtMotherPhone.Text, txtMotherEmail.Text, txtNotes.Text, ddlRenewalOrUpgrade.SelectedValue ); break; default: ContractService.Update( RowID, Convert.ToInt32(ddlPackage.SelectedValue), calDate.SelectedDate.GetValueOrDefault(), calEffectiveDate.SelectedDate.GetValueOrDefault(), txtIDCardNo.Text, ddlOccupation.SelectedIndex == 0 ? (int?)null : Convert.ToInt32(ddlOccupation.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingCardType.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlBillingBank.SelectedValue), txtBillingCardNo.Text, txtBillingCardHolderName.Text, txtBillingCardHolderID.Text, new DateTime(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue), DateTime.DaysInMonth(Convert.ToInt32(ddlCardExpiredYear.SelectedValue), Convert.ToInt32(ddlCardExpiredMonth.SelectedValue))), txtHomePhone.Text, txtCellPhone.Text, txtWorkPhone.Text, txtMailingAddress.Text, txtMailingZipCode.Text, txtAddress.Text, txtZipCode.Text, Convert.ToInt32(ddlArea.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToInt32(ddlMonthlyDuesItem.SelectedValue), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtDuesAmount.Value.GetValueOrDefault()), Convert.ToInt32(ddlBillingType.SelectedValue) == 1 ? 0 : Convert.ToDecimal(txtAdditionalDuesAmount.Value.GetValueOrDefault()), calNextDuesDate.SelectedDate.GetValueOrDefault(), calExpiredDate.SelectedDate.GetValueOrDefault(), chkFather.Checked, txtFatherName.Text, txtIDCardNoFather.Text, chkFatherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateFather.SelectedDate, txtFatherPhone.Text, txtFatherEmail.Text, chkMother.Checked, txtMotherName.Text, txtIDCardNoMother.Text, chkMotherBirthDateUnknown.Checked ? (DateTime?)null : calBirthDateMother.SelectedDate, txtMotherPhone.Text, txtMotherEmail.Text, txtNotes.Text ); break; } Refresh(); } } catch (Exception ex) { WebFormHelper.SetLabelTextWithCssClass(lblMessage, ex.Message, LabelStyleNames.ErrorMessage); LogService.ErrorException(GetType().FullName, ex); } }
public ActionResult Add(Contract _Contract) { _Contract.UserID = _UserService.GetByDefault(x => x.UserName == User.Identity.Name).ID; _ContractService.Add(_Contract); return(Redirect("/SysAdmin/Contract/List")); }