コード例 #1
0
        public CreateInvoiceViewModel(string quoteId, string nextInvoice)
        {
            QuoteId = quoteId;
            Quote        quote         = Quote.GetQuote(quoteId);
            WorkLocation location      = WorkLocation.GetLocation(quote.WorkLocationId);
            Contact      contact       = Contact.GetContact(quote.ContactId);
            var          acceptedWorks = AcceptedWork.GetWorksForQuote(quoteId);

            InvoiceId        = quote.GetCustomerIdentifier() + "-" + nextInvoice;
            Date             = DateTime.Today.ToString("dd-MM-yyyy");
            InvoiceTo        = location.WorkLocationName;
            InvoiceToAddress = location.GetAddress();
            ContactId        = quote.ContactId;
            WorkLocationId   = quote.WorkLocationId;
            CareOf           = contact.GetName();
            CareOfEmail      = contact.Email;
            CareOfNumber     = contact.MobileNumber ?? contact.PhoneNumber;
            InvoiceDetails   = new List <InvoiceDetail>()
            {
                new InvoiceDetail()
                {
                    Description = "Refurbishment to squash courts as agrred",
                    Price       = acceptedWorks.Sum(work => work.Price)
                }
            };
        }
コード例 #2
0
 public ContactDetails(Contact contact, WorkLocation location)
 {
     ClubName      = location.WorkLocationName;
     ClubAddress   = location.GetAddress();
     ContactName   = contact.FirstName + " " + contact.LastName;
     ContactNumber = contact.MobileNumber ?? contact.PhoneNumber;
     ContactEmail  = contact.Email;
 }
コード例 #3
0
ファイル: Contact.cs プロジェクト: rekaburmeister/quoteapp
 public static int CheckAndUpdateContact(int contactId, string contactName, string contactEmail, string contactNumber, int clubId)
 {
     using (ApplicationDbContext database = new ApplicationDbContext())
     {
         Contact      contact  = database.Contacts.Find(contactId);
         WorkLocation location = database.WorkLocations.Find(clubId);
         string[]     names    = contactName.Split(' ');
         if (contact == null)
         {
             contact = new Contact
             {
                 FirstName    = names[0],
                 LastName     = names[names.Length - 1],
                 Email        = contactEmail,
                 MobileNumber = contactNumber
             };
             if (names.Length > 2)
             {
                 contact.MiddleName = string.Join(" ", names, 1, names.Length - 2);
             }
             contact.WorkLocations = new Collection <WorkLocation> {
                 location
             };
             database.Contacts.Add(contact);
             database.SaveChanges();
         }
         //else
         //{
         //    contact.FirstName = names[0];
         //    contact.LastName = names[names.Length - 1];
         //    if (names.Length > 2)
         //    {
         //        contact.MiddleName = string.Join(" ", names, 1, names.Length - 2);
         //    }
         //    contact.Email = contactEmail;
         //    contact.MobileNumber = contactNumber;
         //    if (!contact.WorkLocations.Contains(location))
         //    {
         //        contact.WorkLocations.Add(location);
         //    }
         //    database.Entry(contact).State = EntityState.Modified;
         //}
         //database.SaveChanges();
         return(contact.ContactId);
     }
 }
コード例 #4
0
 public static int CheckAndUpdateLocation(int clubId, string clubAddress, string clubName)
 {
     using (ApplicationDbContext database = new ApplicationDbContext())
     {
         WorkLocation location     = database.WorkLocations.Find(clubId);
         string[]     addressLines = clubAddress.Split(',');
         if (location == null)
         {
             location = new WorkLocation
             {
                 WorkLocationName = clubName,
                 Address1         = addressLines[0],
                 PostCode         = addressLines[addressLines.Length - 1],
                 Town             = addressLines[addressLines.Length - 2]
             };
             if (addressLines.Length > 3)
             {
                 location.Address2 = string.Join(", ", addressLines, 1, addressLines.Length - 2);
             }
             database.WorkLocations.Add(location);
             database.SaveChanges();
         }
         //else
         //{
         //    location.WorkLocationName = clubName;
         //    location.Address1 = addressLines[0];
         //    location.PostCode = addressLines[addressLines.Length - 1];
         //    location.Town = addressLines[addressLines.Length - 2];
         //    if (addressLines.Length > 3)
         //    {
         //        location.Address2 = string.Join(" ", addressLines, 1, addressLines.Length - 2);
         //    }
         //    database.Entry(location).State = EntityState.Modified;
         //}
         //database.SaveChanges();
         return(location.WorkLocationId);
     }
 }