/// <summary>
        /// Insert Seller with Seller Name, Type and BusinessCategory only for specific loan
        /// </summary>
        /// <param name="loanId"></param>
        /// <param name="sellerData"></param>
        /// <returns></returns>
        public BusinessContact InsertSimpleSeller(Guid loanId, FormSeller sellerData)
        {
            BusinessContact contact = new BusinessContact();

            contact.BusinessContactId       = Guid.Empty;
            contact.SellerType              = sellerData.SellerType;
            contact.BusinessContactCategory = BusinessContactCategory.SellerAgent;

            switch (contact.SellerType)
            {
            case SellerType.Individual:
                contact.FirstName = sellerData.SellerName;
                break;

            case SellerType.Bank:
            case SellerType.LLC:
                contact.CompanyName = sellerData.SellerName;
                break;

            default:
                contact.FirstName = sellerData.SellerName;
                break;
            }
            return(BusinessContactServiceFacade.CreateBusinessContactByLoan(loanId, contact));
        }
Beispiel #2
0
        public async Task ContactNote_CreateRetrieveAndDelete()
        {
            //create borrower contact to test notes
            var client = await GetTestClientAsync();

            var businessContact = new BusinessContact
            {
                FirstName     = "test",
                PersonalEmail = "*****@*****.**"
            };
            var contactId = await client.BusinessContacts.CreateContactAsync(businessContact);

            //test notes
            var note = new ContactNote
            {
                Subject = "test",
                Details = "testing data"
            };
            var noteId = await businessContact.Notes.CreateNoteAsync(note);

            Assert.IsNotNull(noteId);

            var newNote = await businessContact.Notes.GetNoteAsync(noteId);

            Assert.IsNotNull(newNote);
            Assert.AreEqual(newNote.NoteId, noteId);

            Assert.IsTrue(await businessContact.Notes.DeleteNoteAsync(noteId).ConfigureAwait(false));

            Assert.IsTrue(await client.BusinessContacts.DeleteContactAsync(contactId).ConfigureAwait(false));
        }
        public async Task <IActionResult> Edit(int id, [Bind("BusinessContactID,BusinessFname,BusinessLname,BusinessEmail,BusinessAddr1,BusinessAddr2,BusinessCity,BusinessPostcode,BusinessTel")] BusinessContact businessContact)
        {
            if (id != businessContact.BusinessContactID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(businessContact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BusinessContactExists(businessContact.BusinessContactID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(businessContact));
        }
        //Update a business contact
        public void updateData(int id, DateTime date, string company, string website, string title, string fName, string lName, string address,
                               string city, string province, string postalCode, string email, string phone, string notes)
        {
            BusinessContact businessContact = (from b in _context.BusinessContacts
                                               where b.ID == id
                                               select b).FirstOrDefault();

            if (businessContact != null)
            {
                businessContact.Date_Added  = date;
                businessContact.Company     = company;
                businessContact.Website     = website;
                businessContact.Title       = title;
                businessContact.First_Name  = fName;
                businessContact.Last_Name   = lName;
                businessContact.City        = city;
                businessContact.Province    = province;
                businessContact.Postal_Code = postalCode;
                businessContact.Email       = email;
                businessContact.Phone       = phone;
                businessContact.Notes       = notes;

                _context.SaveChanges();
            }
        }
        public ActionResult ReturnBook()
        {
            var model = new ReturnBookModel();

            model.Contacts = BusinessContact.GetContacts();

            return(View("ReturnBook", model));
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var faker   = new Faker("en");
            var isValid = ValidateInput();

            if (isValid)
            {
                try
                {
                    Address address = new Address
                    {
                        AddressLine1 = tbAddressLine1.Text,
                        AddressLine2 = tbAddressLine2.Text,
                        City         = tbCity.Text,
                        State        = tbState.Text,
                        Country      = tbCountry.Text,
                        PostalCode   = tbPostalCode.Text
                    };
                    _context.Addresses.Add(address);
                    _context.SaveChanges();
                    int addressID = _context.Addresses.Select(i => i.AddressID).Max();

                    BusinessContact contact = new BusinessContact
                    {
                        EmailAddress      = tbEmail.Text,
                        Telephone         = tbTelephone.Text,
                        BusinessTelephone = tbBusinessTelephone.Text,
                        AddressID         = addressID
                    };
                    _context.BusinessContacts.Add(contact);
                    _context.SaveChanges();
                    int contactID = _context.PersonalContacts.Select(i => i.PersonalContactID).Max();

                    Employee employee = new Employee()
                    {
                        FirstName = tbFirstName.Text,
                        LastName  = tbLastName.Text,
                        BirthDate = tbBirthDate.Value,
                        NationalInsuranceNumber = faker.Internet.Mac(),
                        HireDate          = DateTime.Now,
                        PositionID        = _positions.FirstOrDefault(i => i.Name == tbPosition.Text).PositionID,
                        BusinessContactID = contactID
                    };
                    _context.Employees.Add(employee);
                    _context.SaveChanges();
                    MessageBox.Show("New Employee Added!", "New Employee", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please fill in the required fields.", "New Employee", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #7
0
        public void BusinessContact_Serialization()
        {
#pragma warning disable CS0618 // Type or member is obsolete
            var businessContact = new BusinessContact { AccessLevel = ContactAccessLevel.Private };
#pragma warning restore CS0618 // Type or member is obsolete
            Assert.AreEqual(@"{""accessLevel"":0}", businessContact.ToString(SerializationOptions.Dirty));
            businessContact.Dirty = false;
            Assert.AreEqual("{}", businessContact.ToString(SerializationOptions.Dirty));
        }
        public async Task <IActionResult> Edit(int id, [Bind("EmployeeID,FirstName,LastName,BirthDate,Position,EmailAddress,Telephone,BusinessTelephone,AddressLine1,AddressLine2,City,State,Country,PostalCode")] vwBusinessContactDetail vwBusinessContactDetail)
        {
            if (id != vwBusinessContactDetail.EmployeeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var model = vwBusinessContactDetail;

                try
                {
                    var vwPosition   = _context.vwPositions.FirstOrDefault(i => i.Position == model.Position);
                    int positionID   = vwPosition.PositionID;
                    int departmentID = vwPosition.DepartmentID;

                    Employee employee = _context.Employees.Find(id);
                    employee.FirstName  = model.FirstName;
                    employee.LastName   = model.LastName;
                    employee.BirthDate  = model.BirthDate;
                    employee.PositionID = positionID;
                    _context.Employees.Update(employee);

                    BusinessContact contact = _context.BusinessContacts.Find(employee.BusinessContactID);
                    contact.EmailAddress      = model.EmailAddress;
                    contact.Telephone         = model.Telephone;
                    contact.BusinessTelephone = model.BusinessTelephone;
                    _context.BusinessContacts.Update(contact);

                    Address address = _context.Addresses.Find(contact.AddressID);
                    address.AddressLine1 = model.AddressLine1;
                    address.AddressLine2 = model.AddressLine2;
                    address.City         = model.City;
                    address.State        = model.State;
                    address.Country      = model.Country;
                    address.PostalCode   = model.PostalCode;
                    _context.Addresses.Update(address);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!vwBusinessContactDetailExists(vwBusinessContactDetail.EmployeeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewData["Position"] = new SelectList(_context.Positions, "Name", "Name", vwBusinessContactDetail.Position);
            return(View(vwBusinessContactDetail));
        }
Beispiel #9
0
        public void BusinessContact_Serialization()
        {
            var businessContact = new BusinessContact {
                AccessLevel = ContactAccessLevel.Private
            };

            Assert.AreEqual(@"{""accessLevel"":0}", businessContact.ToJson());
            businessContact.Dirty = false;
            Assert.AreEqual("{}", businessContact.ToJson());
        }
Beispiel #10
0
 public static Activity GenerateMappedRecord(BusinessContact businessContact, MembershipUser admin)
 {
     return(new Activity
     {
         Data = KeyBusinessContactId + Equality + businessContact.Id + Separator +
                KeyAdminId + Equality + admin.Id,
         Timestamp = businessContact.CreateDate,
         Type = ActivityType.AdminBusinessContactAdded.ToString()
     });
 }
        public async Task <IActionResult> Create([Bind("BusinessContactID,BusinessFname,BusinessLname,BusinessEmail,BusinessAddr1,BusinessAddr2,BusinessCity,BusinessPostcode,BusinessTel")] BusinessContact businessContact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(businessContact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(businessContact));
        }
        //Delete a business contact
        public void deleteData(int id)
        {
            BusinessContact businessContact = (from b in _context.BusinessContacts
                                               where b.ID == id
                                               select b).FirstOrDefault();

            if (businessContact != null)
            {
                _context.BusinessContacts.Remove(businessContact);
                _context.SaveChanges();
            }
        }
Beispiel #13
0
        public bool ActivateLicense(LicenseActivationDetail lad)
        {
            try
            {
                var catalog = _unitOfWork.GetRepository <CustomerCatalogGroup>().Single(x => x.CustomerCatalogGroupId == lad.CustomerCatalogGroupId);



                BusinessContact businessContact = new BusinessContact();
                businessContact.BusinessName = lad.BusinessName;
                businessContact.MobileNumber = lad.MobileNo;

                Contact contact = new Contact();
                contact.FirstName = lad.ContactPersonName;

                businessContact.ContactPerson = contact;

                Customer cus = new Customer();
                cus.BusinessContact = businessContact;
                cus.CustomerEmailId = lad.EmailId;
                cus.MobileNo        = lad.MobileNo;

                catalog.NumberofSystem = 1;
                catalog.Customer       = cus;
                LicenseRenewedDetail licenseRenewed = new LicenseRenewedDetail();
                licenseRenewed.CustomerCatalogGroupId = catalog.Id;
                licenseRenewed.RenewedDate            = System.DateTime.Now;
                licenseRenewed.ExpiryDate             = System.DateTime.Now.AddDays(10);

                _unitOfWork.GetRepository <LicenseRenewedDetail>().Add(licenseRenewed);

                catalog.RenewedDetailId = licenseRenewed.Id;

                _unitOfWork.GetRepository <BusinessContact>().Add(businessContact);
                _unitOfWork.GetRepository <Contact>().Add(contact);
                _unitOfWork.GetRepository <Customer>().Add(cus);

                _unitOfWork.GetRepository <CustomerCatalogGroup>().Update(catalog);

                //LicensedHardware licensedHardware = new LicensedHardware();
                //licensedHardware.HardwareId = lad.HardwareId;
                //licensedHardware.CustomerCatalogGroupId = catalog.Id;
                //licensedHardware.ActivatedDate = System.DateTime.Now;
                //_unitOfWork.GetRepository<LicensedHardware>().Add(licensedHardware);
                _unitOfWork.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(false);
            }
        }
        public ActionResult LendBook()
        {
            if (!ModelState.IsValid)
            {
                return(View("LendBook"));
            }
            var model = new LendBookModel();

            model.Products = BusinessProduct.GetProducts();
            model.Contacts = BusinessContact.GetContacts();
            return(View("LendBook", model));
        }
Beispiel #15
0
        public void RemoveBusinessContact(Guid userId, Guid contactId)
        {
            BusinessContact contact = new BusinessContact
            {
                Id     = contactId,
                UserId = userId
            };

            _context.BusinessContact.Remove(contact);

            _context.SaveChanges();
        }
Beispiel #16
0
        public BusinessContact PopulateBusinessContactFromLoanContact(object loancompanyType, object loanContactType, Guid loanId)
        {
            LoanCompany loancompany = (LoanCompany)loancompanyType;
            LoanContact loanContact = (LoanContact)loanContactType;
            Seller      seller      = new Seller()
            {
                FirstNameSeller                 = loanContact.FirstName,
                LastNameSeller                  = loanContact.LastName,
                ContactPhonePreferredSeller     = loanContact.PhoneNumber,
                ContactPhonePreferredSellerType = ( PhoneNumberType )loanContact.PhoneNumberType,
                ContactPhoneAlternateSeller     = loanContact.AlternatePhoneNumber,
                ContactPhoneAlternateSellerType = ( PhoneNumberType )loanContact.AlternatePhoneNumberType,
                EmailSeller = loanContact.Email
            };

            // Address information

            Address address = new Address()
            {
                StreetName = loancompany.StreetAddress,
                ZipCode    = loancompany.Zip,
                CityName   = loancompany.City,
                StateId    = loancompany.StateId,
            };

            // Business contact information

            BusinessContact businessContact = new BusinessContact()
            {
                BusinessContactCategory = ( BusinessContactCategory )loancompany.ContactType,
                CompanyContactsType     = loancompany.ContactType,
                Seller                     = seller,
                LoanId                     = loanId,
                Address                    = address,
                CompanyName                = loancompany.CompanyName,
                FirstName                  = loanContact.FirstName,
                LastName                   = loanContact.LastName,
                Email                      = loanContact.Email,
                ReferenceNumber            = loanContact.ReferenceNumber,
                LoanContactsCompanyId      = loancompany.CompanyId,
                LoanContactsContactId      = loanContact.ContactId,
                LoanContactsContactType    = loancompany.ContactType > -1 ? loancompany.ContactType : -1,
                IsLoanApplicationCompleted = loanContact.IsLoanApplicationCompleted,
                IsContactFromCoBrandedSite = loanContact.IsContactFromCoBrandedSite
            };

            if (loanContactType is LoanRealtorContact)
            {
                LoanRealtorContact realtor = (LoanRealtorContact)loanContactType;
                businessContact.LoanContactsContactSubType = realtor.SubType;
            }
            return(businessContact);
        }
        public async Task <IActionResult> Create([Bind("EmployeeID,FirstName,LastName,BirthDate,Position,EmailAddress,Telephone,BusinessTelephone,AddressLine1,AddressLine2,City,State,Country,PostalCode")] vwBusinessContactDetail vwBusinessContactDetail)
        {
            if (ModelState.IsValid)
            {
                var model        = vwBusinessContactDetail;
                var vwPosition   = _context.vwPositions.FirstOrDefault(i => i.Position == model.Position);
                int positionID   = vwPosition.PositionID;
                int departmentID = vwPosition.DepartmentID;

                Address address = new Address
                {
                    AddressLine1 = model.AddressLine1,
                    AddressLine2 = model.AddressLine2,
                    City         = model.City,
                    State        = model.State,
                    Country      = model.Country,
                    PostalCode   = model.PostalCode
                };
                _context.Addresses.Add(address);
                _context.SaveChanges();
                int addressID = _context.Addresses.Select(i => i.AddressID).Max();

                BusinessContact contact = new BusinessContact
                {
                    EmailAddress      = model.EmailAddress,
                    Telephone         = model.Telephone,
                    BusinessTelephone = model.BusinessTelephone,
                    AddressID         = addressID
                };
                _context.BusinessContacts.Add(contact);
                _context.SaveChanges();
                int contactID = _context.BusinessContacts.Select(i => i.BusinessContactID).Max();

                Employee employee = new Employee()
                {
                    FirstName = model.FirstName,
                    LastName  = model.LastName,
                    BirthDate = model.BirthDate,
                    NationalInsuranceNumber = "c6:8a:24:1f:f7:25",
                    HireDate          = DateTime.Now,
                    PositionID        = positionID,
                    BusinessContactID = contactID
                };
                _context.Employees.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["Position"] = new SelectList(_context.Positions, "Name", "Name", vwBusinessContactDetail.Position);
            return(View(vwBusinessContactDetail));
        }
        public ActionResult Index()
        {
            Contacts.Instance.Clear();
            Contacts.Instance.AddRange(BusinessContact.Load());

            var model = new List <ContactViewModel>();

            foreach (var p in Contacts.Instance)
            {
                model.Add(new ContactViewModel(p));
            }
            return(View(model));
        }
        public async Task ContactNote_CreateRetrieveAndDelete()
        {
            //create borrower contact to test notes
            var client = await GetTestClientAsync();

            var businessContact = new BusinessContact("test", "*****@*****.**");
            var contactId       = await client.Contacts.BusinessContacts.CreateContactAsync(businessContact);

            try
            {
                //test notes
                var note   = new ContactNote("test", "testing data");
                var noteId = await businessContact.Notes.CreateNoteAsync(note);

                Assert.IsNotNull(noteId);

                var retrievedNote = await businessContact.Notes.GetNoteAsync(noteId);

                Assert.IsNotNull(retrievedNote);
                Assert.AreEqual(noteId, retrievedNote.NoteId);
                Assert.AreEqual(note.Subject, retrievedNote.Subject);
                Assert.AreEqual(note.Details, retrievedNote.Details);

                note = new ContactNote(noteId)
                {
                    Subject = "New Subject", Details = "New Details"
                };
                await businessContact.Notes.UpdateNoteAsync(note);

                retrievedNote = await businessContact.Notes.GetNoteAsync(noteId);

                Assert.IsNotNull(retrievedNote);
                Assert.AreEqual(noteId, retrievedNote.NoteId);
                Assert.AreEqual(note.Subject, retrievedNote.Subject);
                Assert.AreEqual(note.Details, retrievedNote.Details);

                Assert.IsTrue(await businessContact.Notes.TryDeleteNoteAsync(noteId));
                Assert.IsFalse(await businessContact.Notes.TryDeleteNoteAsync(noteId));
            }
            finally
            {
                try
                {
                    await client.Contacts.BusinessContacts.DeleteContactAsync(contactId);
                }
                catch
                {
                }
            }
        }
Beispiel #20
0
        public void AdminBusinessContactAdded(BusinessContact businessContact, MembershipUser admin)
        {
            var e = new AdminAddBusinessContactEventArgs {
                BusinessContact = businessContact, Admin = admin
            };

            EventManager.Instance.FireBeforeAdminBusinessContactAdd(this, e);
            if (!e.Cancel)
            {
                EventManager.Instance.FireAfterAdminBusinessContactAdd(this, new AdminAddBusinessContactEventArgs {
                    BusinessContact = businessContact, Admin = admin
                });
                _activityService.AdminBusinessContactAdded(businessContact, admin);
            }
        }
Beispiel #21
0
        public void EditContact(BusinessContact fullContact)
        {
            var contact = _context.BusinessContact.FirstOrDefault(x => x.Id == fullContact.Id);

            if (contact != null)
            {
                contact.Eamil     = fullContact.Eamil;
                contact.Name      = fullContact.Name;
                contact.AddressId = fullContact.AddressId;

                _context.BusinessContact.Update(contact);

                _context.SaveChanges();
            }
        }
        public ActionResult AddCustomer([Bind(Include = "Id,FirstName,LastName")] ContactEditModel e)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddCustomer", e));
            }
            var contact = new ContactInstance {
                Contact = new Contacts()
            };

            contact.UniqueId = GetRandom.String();
            e.Update(contact);
            BusinessContact.SaveContactInstance(contact);
            return(RedirectToAction("Index"));
        }
        public ActionResult EditCustomer([Bind(Include = "Id,FirstName,LastName")] ContactEditModel c)
        {
            if (!ModelState.IsValid)
            {
                return(View("EditCustomer", c));
            }
            var contact = Contacts.Instance.Find(x => x.IsThisUniqueId(c.Id));

            if (contact == null)
            {
                return(HttpNotFound());
            }
            c.Update(contact);
            BusinessContact.UpdateContactInstance(contact);
            return(RedirectToAction("Index"));
        }
Beispiel #24
0
        public async Task BusinessContact_CreateRetrieveAndDelete()
        {
            var client = await GetTestClientAsync();

            var businessContact = new BusinessContact("Bob", "*****@*****.**");
            var contactId       = await client.BusinessContacts.CreateContactAsync(businessContact);

            try
            {
                Assert.IsNotNull(contactId);
                Assert.AreEqual(contactId, businessContact.Id);

                var retrievedContact = await client.BusinessContacts.GetContactAsync(contactId);

                Assert.IsNotNull(retrievedContact);
                Assert.AreEqual(contactId, retrievedContact.Id);
                Assert.AreEqual(businessContact.FirstName, retrievedContact.FirstName);
                Assert.AreEqual(businessContact.PersonalEmail, retrievedContact.PersonalEmail);
                Assert.IsTrue(string.IsNullOrEmpty(retrievedContact.LastName));

                businessContact = new BusinessContact(client, contactId, "Bob", "*****@*****.**")
                {
                    LastName = "Smith"
                };
                await client.BusinessContacts.UpdateContactAsync(businessContact);

                retrievedContact = await client.BusinessContacts.GetContactAsync(contactId);

                Assert.IsNotNull(retrievedContact);
                Assert.AreEqual(contactId, retrievedContact.Id);
                Assert.AreEqual("Bob", retrievedContact.FirstName);
                Assert.AreEqual("*****@*****.**", retrievedContact.PersonalEmail);
                Assert.AreEqual("Smith", retrievedContact.LastName);
            }
            finally
            {
                try
                {
                    await client.BusinessContacts.DeleteContactAsync(contactId);
                }
                catch
                {
                }
            }
        }
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var contact = Contacts.Instance.Find(x => x.IsThisUniqueId(id));

            if (contact == null)
            {
                return(HttpNotFound());
            }
            if (contact.Contact != null)
            {
                BusinessContact.DeleteContactInstance(contact);
            }
            return(RedirectToAction("Index"));
        }
Beispiel #26
0
        public ActionResult AddPOC(BusinessContactViewModel viewModel)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                var loggedOnUserId = LoggedOnReadOnlyUser?.Id ?? Guid.Empty;
                var admin          = MembershipService.Get(loggedOnUserId);
                var settings       = SettingsService.GetSettings();
                var business       = _businessService.Get(viewModel.Id);

                var newContact = new BusinessContact
                {
                    FirstName    = viewModel.FirstName,
                    LastName     = viewModel.LastName,
                    PrimaryPhone = viewModel.PrimaryPhoneNumber,
                    Email        = viewModel.Email,
                    Business     = business
                };

                try
                {
                    _businessService.AddBusinessContact(newContact);
                    _businessService.AdminBusinessContactAdded(newContact, admin);
                    unitOfWork.Commit();
                    TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                    {
                        Message     = "Business Contact Added.",
                        MessageType = GenericMessages.success
                    };
                    return(RedirectToAction("POC", "AdminBusiness", new { id = business.Id }));
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    //LoggingService.Error(ex);
                    TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                    {
                        Message     = "Adding a business contact failed.",
                        MessageType = GenericMessages.danger
                    };
                }

                return(RedirectToAction("POC", "AdminBusiness", new { id = business.Id }));
            }
        }
Beispiel #27
0
    static void GenerateFakeContacts(AddressBook addressBook)
    {
        // 1. Lägg till kontakt via UI så småningom
        BusinessContact nyKontakt;

        nyKontakt           = new BusinessContact();
        nyKontakt.FirstName = "Lisa";
        nyKontakt.Company   = "BY";

        addressBook.Add(nyKontakt);

        PrivateContact nyPrivatKontakt = new PrivateContact();

        nyPrivatKontakt.FirstName    = "Arne";
        nyPrivatKontakt.RelationType = "It's complicated";
        nyPrivatKontakt.Birthday     = new DateTime(1981, 6, 1);

        addressBook.Add(nyPrivatKontakt);
    }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var isValid = ValidateInput();

            if (isValid)
            {
                try
                {
                    Employee employee = _context.Employees.Find(_employeeID);
                    employee.FirstName  = tbFirstName.Text;
                    employee.LastName   = tbLastName.Text;
                    employee.BirthDate  = tbBirthDate.Value;
                    employee.PositionID = _positions.FirstOrDefault(i => i.Name == tbPosition.Text).PositionID;
                    _context.Employees.Update(employee);

                    BusinessContact contact = _context.BusinessContacts.Find(employee.BusinessContactID);
                    contact.EmailAddress      = tbEmail.Text;
                    contact.Telephone         = tbTelephone.Text;
                    contact.BusinessTelephone = tbBusinessTelephone.Text;
                    _context.BusinessContacts.Update(contact);

                    Address address = _context.Addresses.Find(contact.AddressID);
                    address.AddressLine1 = tbAddressLine1.Text;
                    address.AddressLine2 = tbAddressLine2.Text;
                    address.City         = tbCity.Text;
                    address.State        = tbState.Text;
                    address.Country      = tbCountry.Text;
                    address.PostalCode   = tbPostalCode.Text;
                    _context.Addresses.Update(address);
                    _context.SaveChanges();
                    MessageBox.Show("Employee Updated!", "Edit Employee", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please fill in the required fields.", "Edit Employee", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #29
0
        static void PrintContact(Contact minKontakt)
        {
            Console.WriteLine("FirstName: " + minKontakt.FirstName);
            Console.WriteLine("LastName: " + minKontakt.LastName);

            BusinessContact bs = minKontakt as BusinessContact;

            Type typen = minKontakt.GetType();

            // typeof(Contact);
            if (minKontakt is PrivateContact privateContact)
            {
                Console.WriteLine("Birthday: " + privateContact.Birthday.ToString("yyyy/MM/dd"));
            }
            else if (minKontakt is BusinessContact bc)
            {
                Console.WriteLine("Company: " + bc.Company);
            }
            Console.WriteLine();
        }
Beispiel #30
0
        public async Task BusinessContact_CreateRetrieveAndDelete()
        {
            var client = await GetTestClientAsync();

            var businessContact = new BusinessContact
            {
                FirstName     = "Bob",
                PersonalEmail = "*****@*****.**"
            };
            var contactId = await client.BusinessContacts.CreateContactAsync(businessContact).ConfigureAwait(false);

            Assert.IsNotNull(contactId);
            Assert.AreEqual(contactId, businessContact.Id);

            var retrievedContact = await client.BusinessContacts.GetContactAsync(contactId);

            Assert.IsNotNull(retrievedContact);
            Assert.AreEqual(contactId, retrievedContact.Id);

            Assert.IsTrue(await client.BusinessContacts.DeleteContactAsync(contactId).ConfigureAwait(false));
        }
     /// <summary>
     /// Adds an BusinessContact object to the DbSet of BusinessContacts
     /// </summary>
     /// <typeparam name="BusinessContact">The BusinessContact to be added.</param>
     protected virtual void _Add(BusinessContact obj) {
 
             DB.BusinessContacts.Add(obj); 
             DB.SaveChanges();
         
     }
     /// <summary>
     /// Deletes an BusinessContact object to the DbSet of BusinessContacts
     /// </summary>
     /// <typeparam name="BusinessContact">The BusinessContact to be deleted.</param>
     protected virtual void _Delete(BusinessContact obj) {
 
             DB.Entry<BusinessContact>(obj).State = EntityState.Deleted;
             DB.SaveChanges();
         
     }