//
 // GET: /CompanyInvoice/Create
 //
 public ActionResult Create(int id)
 {
     Company company = _repository.GetCompanyById(id);
     if (company == null)
     {
         return View("CompanyNotFound");
     }
     DateTime now = DateTime.Now;
     var ci = new CompanyInvoice
                 {
                     Company = company,
                     created = now,
                     last_sent = now,
                     paid = false,
                     marked_paid_date = now
                 };
     _repository.AddCompanyInvoice(ci);
     _repository.Save();
     return RedirectToAction("Edit", new { ci.id });
 }
 public void DeleteCompanyInvoice(CompanyInvoice ci)
 {
     _companyInvoices.Remove(ci);
 }
 public void AddCompanyInvoice(CompanyInvoice ci)
 {
     ci.id = ++_companyInvoicesMaxId;
     _companyInvoices.Add(ci);
 }
 /// <summary>
 /// Helper method to create CompanyInvoiceEmailEditData objects
 /// </summary>
 /// <param name="ci">The company invoice from which to take the id and company id</param>
 /// <returns>A CompanyInvoiceEmailEditData object from the CompanyInvoice</returns>
 private CompanyInvoiceEmailEditData MakeEmailEditData(CompanyInvoice ci)
 {
     var cieed = new CompanyInvoiceEmailEditData
                     {
                         //TODO: populate subject and body with default data from settings data
                         SelectedRecipiants = new int[0],
                         CompanyInvoiceId = ci.id,
                         PeopleChoices =
                             _repository.GetAllCompanyPersons().Where(
                                 x => x.company_id == ci.company_id)
                                 .OrderByDescending(x => x.is_contact),
                         InvoiceAttachmentFileName = "Invoice" + ci.id + ".pdf"//TODO: localize
                     };
     return cieed;
 }
 public void DeleteCompanyInvoice(CompanyInvoice ci)
 {
     _conferenceware.CompanyInvoices.DeleteOnSubmit(ci);
 }
 public void AddCompanyInvoice(CompanyInvoice ci)
 {
     _conferenceware.CompanyInvoices.InsertOnSubmit(ci);
 }
 partial void DeleteCompanyInvoice(CompanyInvoice instance);
 partial void UpdateCompanyInvoice(CompanyInvoice instance);
 partial void InsertCompanyInvoice(CompanyInvoice instance);
		private void detach_CompanyInvoices(CompanyInvoice entity)
		{
			this.SendPropertyChanging();
			entity.Company = null;
		}
		private void attach_CompanyInvoices(CompanyInvoice entity)
		{
			this.SendPropertyChanging();
			entity.Company = this;
		}