public ActionResult Create(FormCollection collection)
 {
     var cp = new CompanyPayment();
     // This will try to update all the fields in the model based on the form collection
     if (TryUpdateModel(cp,
                        new[] { "company_id", "amount", "received_date", "comments" },
                        collection))
     {
         if (cp.comments == null)
         {
             cp.comments = "";
         }
         _repository.AddCompanyPayment(cp);
         _repository.Save();
         TempData["Message"] = "Payment added";
         return RedirectToAction("Details", "Company", new { id = cp.company_id });
     }
     // if it errors on submit; it only has the id, not the linq object
     Company company = _repository.GetCompanyById(cp.company_id);
     if (company == null)
     {
         // this has happened; not sure why
         TempData["Message"] = "An error has occurred. Please try again";
         RedirectToAction("Index", "Company");
     }
     cp.Company = company;
     return View("Create", cp);
 }
 //
 // GET: /CompanyPayment/Create
 //
 public ActionResult Create(int id)
 {
     Company company = _repository.GetCompanyById(id);
     if (company == null)
     {
         return View("CompanyNotFound");
     }
     var payment = new CompanyPayment { Company = company };
     return View("Create", payment);
 }
Пример #3
0
 public void DeleteCompanyPayment(CompanyPayment cp)
 {
     _companyPayments.Remove(cp);
 }
Пример #4
0
 public void AddCompanyPayment(CompanyPayment cp)
 {
     cp.id = ++_companyPaymentsMaxId;
     _companyPayments.Add(cp);
 }
 public void AddCompanyPayment(CompanyPayment cp)
 {
     _conferenceware.CompanyPayments.InsertOnSubmit(cp);
 }
 public void DeleteCompanyPayment(CompanyPayment cp)
 {
     _conferenceware.CompanyPayments.DeleteOnSubmit(cp);
 }
 partial void DeleteCompanyPayment(CompanyPayment instance);
 partial void UpdateCompanyPayment(CompanyPayment instance);
 partial void InsertCompanyPayment(CompanyPayment instance);
		private void detach_CompanyPayments(CompanyPayment entity)
		{
			this.SendPropertyChanging();
			entity.Company = null;
		}
		private void attach_CompanyPayments(CompanyPayment entity)
		{
			this.SendPropertyChanging();
			entity.Company = this;
		}