private bool ValideContactData(ContactBO contact)
        {
            if (contact == null)
            {
                throw new InvalidContactException("Please supply a valid value for contact");
            }

            if (string.IsNullOrEmpty(contact.FirstName))
            {
                throw new InvalidContactException("First name is required");
            }

            if (string.IsNullOrEmpty(contact.LastName))
            {
                throw new InvalidContactException("Last name is required");
            }

            if (string.IsNullOrEmpty(contact.PhoneNumber))
            {
                throw new InvalidContactException("Phone number is required");
            }

            if (string.IsNullOrEmpty(contact.Email))
            {
                throw new InvalidContactException("Email is required");
            }

            return(true);
        }
コード例 #2
0
        public void TestUpdateEntiyWithGet(ContactDto _ContactDto)
        {
            IContactBO _ContactBO = new ContactBO(new FakeContactConverter());
            var        dbResult   = _ContactBO.UpdateEntiyWithGet(_ContactDto);

            Assert.NotNull(dbResult);
        }
コード例 #3
0
        public SurfaceMineralOwnershipVM(ContactBO BO)
        {
            this.ContactID = BO.Contact.ContactID;
            this.ContactTypeID = BO.Contact.ContactTypeID;
            this.ContactClassID = BO.Contact.ContactClassID;
            this.PermitKey = BO.Contact.PermitKey;
            this.SalutationID = BO.Contact.SalutationID;
            this.FirstName = BO.Contact.FirstName;
            this.LastName = BO.Contact.LastName;
            this.CompanyName = BO.Contact.CompanyName;
            this.OwnershipStatusID = BO.Contact.OwnershipStatusID;
            this.OwnershipTypeID = BO.Contact.OwnershipTypeID;
            this.Phone = BO.Contact.Phone;
            this.PhoneExtension = BO.Contact.PhoneExtension;
            this.Fax = BO.Contact.Fax;
            this.Email = BO.Contact.Email;
            this.AddressID = BO.Addresses[0].AddressID;
            this.Address11 = BO.Addresses[0].Address1;
            this.Address12 = BO.Addresses[0].Address2;
            this.AddressTypeID = BO.Addresses[0].AddressTypeID;
            this.POBox = BO.Addresses[0].POBox;
            this.City = BO.Addresses[0].City;
            this.StateID = BO.Addresses[0].StateID;
            this.ZipCode = BO.Addresses[0].Zipcode;

            SetupSalutationDropdown();
            SetupOwnershipTypeDropdown();
            SetupOwnershipStatusDropdown();
            SetupAddressTypeDropdown();
            SetupStateDropdown();
        }
コード例 #4
0
        public void TestDeleteEntiy(ContactDto _ContactDto)
        {
            IContactBO _ContactBO = new ContactBO(new FakeContactConverter());
            bool       isDeleted  = _ContactBO.DeleteEntiy(_ContactDto);

            Assert.True(isDeleted);
        }
コード例 #5
0
        public void TestUpdateWithAttachEntiy(ContactDto _ContactDto)
        {
            IContactBO _ContactBO = new ContactBO(new FakeContactConverter());
            bool       isUpdated  = _ContactBO.UpdateWithAttachEntiy(_ContactDto);

            Assert.True(isUpdated);
        }
コード例 #6
0
 public OtherPermitsVM(ContactBO BO)
 {
     this.ContactID = BO.Contact.ContactID;
     this.ContactTypeID = BO.Contact.ContactTypeID;
     this.PermitKey = BO.Contact.PermitKey;
     this.OtherPermitTypeID = BO.Contact.OtherPermitTypeID;
     this.OtherPermitStatusID = BO.Contact.OtherPermitStatusID;
     this.Description = BO.Contact.Description;
     this.CompanyName = BO.Contact.CompanyName;
     this.NameOfIssuingAuthority = BO.Contact.NameOfIssuingAuthority;
     this.DateOfApproval = BO.Contact.DateOfApproval;
     this.DateOfDenial = BO.Contact.DateOfDenial;
     this.OtherPermitApplicationOrId = BO.Contact.OtherPermitApplicationOrId;
     this.MSHAID = BO.Contact.MSHAID;
     this.TaxID = BO.Contact.TaxID;
     if (BO.Addresses.Count > 0)
     {
         this.AddressID = BO.Addresses[0].AddressID;
         this.Address11 = BO.Addresses[0].Address1;
         this.Address12 = BO.Addresses[0].Address2;
         this.AddressTypeID = BO.Addresses[0].AddressTypeID;
         this.POBox = BO.Addresses[0].POBox;
         this.City = BO.Addresses[0].City;
         this.StateID = BO.Addresses[0].StateID;
         this.ZipCode = BO.Addresses[0].Zipcode;
     }
     SetupOtherPermitTypes();
     SetupOtherPermitStatus();
     SetupAddressTypeDropdown();
     SetupStateDropdown();
 }
コード例 #7
0
        public void TestAdd(ContactDto _ContactDto)
        {
            IContactBO _ContactBO = new ContactBO(new FakeContactConverter());
            bool       hasAdded   = _ContactBO.CreateEntiy(_ContactDto);

            Assert.True(hasAdded);
        }
コード例 #8
0
 private void btnEditContact_Click(object sender, RoutedEventArgs e)
 {
     if (lvContacts.SelectedItem != null)
     {
         PersonBO  cc      = lvPersons.SelectedItem as PersonBO;
         ContactBO contact = new ContactBO((lvContacts.SelectedItem as ContactBO).Id, contactValueBox.Text, (lvPersons.SelectedItem as PersonBO).Id, ((cBoxContactTypes.SelectedItem) as ContactTypeBO).Id);
         if (contact.Id == 1 || cBoxContactTypes.SelectedItem.Equals("Email"))
         {
             if (!IsValid(contactValueBox.Text))
             {
                 MessageBoxResult result = MessageBox.Show("The email is invalid, aborting", "Warning", MessageBoxButton.OK);
                 return;
             }
         }
         contact.AddOrUpdate();
         this._vm._contacts     = cc.Contacts;
         lvContacts.ItemsSource = _vm.Contacts;
         lvContacts.UpdateLayout();
     }
     else
     {
         MessageBoxResult result = MessageBox.Show("Select a Contact to edit first", "Warning", MessageBoxButton.OK);
     }
     e.Handled = true;
 }
コード例 #9
0
ファイル: ContactBOTests.cs プロジェクト: mo5h/omeo
        [Test] public void CreationContactBodyTest3()
        {
            string    displayName = "'Sergey Zhulin'";
            ContactBO contact     = (ContactBO)_contactManager.FindOrCreateContact(null, displayName);

            Assert.AreEqual(false, contact.Changed);

            int id = contact.Resource.Id;

            contact.Birthday = new DateTime(1972, 07, 26);
            contact.Company  = "JetBrains";
            contact.HomePage = "www.jetbrains.ru";
            contact.JobTitle = "Developer";
            contact.Address  = "Sertolovo";

            IResource contactName = Core.ResourceStore.BeginNewResource("ContactName");

            contactName.SetProp("Name", "Sergeyy Zhulinn");
            contactName.SetProp(Core.ContactManager.Props.LinkBaseContact, contact.Resource);
            contactName.EndUpdate();

            IResource contactName2 = Core.ResourceStore.BeginNewResource("ContactName");

            contactName2.SetProp("Name", "Sergeyyy Zhulinnn");
            contactName2.SetProp(Core.ContactManager.Props.LinkBaseContact, contact.Resource);
            contactName2.EndUpdate();

            contact = (ContactBO)_contactManager.FindOrCreateContact(null, displayName);
            Assert.AreEqual(false, contact.Changed);
            Assert.AreEqual("Sergey Zhulin Sertolovo JetBrains Developer www.jetbrains.ru |Sergeyy Zhulinn Sergeyyy Zhulinnn |", contact.ContactBody);
            Assert.AreEqual(id, contact.ID);
        }
コード例 #10
0
        public IResource AfterDeserialize(IResource parentResource, IResource phone, System.Xml.XmlNode node)
        {
            //  Search for account only if we deal with completely consistent chain
            //  of the resources - parent must be a Contact, resource must be a Phone
            if (parentResource.Type != "Contact" && phone.Type != "Phone")
            {
                throw new ArgumentException("PhoneDeserialization -- Illegal types of input parameters: [" + parentResource.Type + "] and [" + phone.Type + "]");
            }

            ContactBO contact        = new ContactBO(parentResource);
            string    newPhoneNumber = phone.GetStringProp(ContactManager._propPhoneNumber);
            string    newPhoneName   = phone.GetStringProp(ContactManager._propPhoneName);

            //  Do not add phone if it is number already exist (even under the
            //  name possibly).
            IResource contactPhone = contact.GetPhoneByNumber(newPhoneNumber);

            if (contactPhone != null)
            {
                return(contactPhone);
            }

            //  If the phone with such name already exist, find more suitable
            //  name for a newly coming phone number - add numeric prefix for
            //  its name.
            contactPhone = contact.GetPhoneByName(newPhoneName);
            if (contactPhone != null)
            {
                string newName = ContactManager.ComposeSuitablePhoneName(contact, newPhoneName);
                phone.SetProp(ContactManager._propPhoneName, newName);
            }

            return(phone);
        }
        /// <summary>
        /// Insert contact.
        /// </summary>
        /// <param name="contact">Contact to be inserted</param>
        public int InsertContact(ContactBO contact)
        {
            ValideContactData(contact);
            var contactDO = ContactConverter.FromBOToDO(contact);
            var contactId = ContactInformationDataManager.InsertContact(contactDO);

            return(contactId);
        }
コード例 #12
0
 public override void EditResource(IResource res)
 {
     _contact = new ContactBO(res);
     foreach (AbstractContactViewBlock block in _contactBlocks)
     {
         block.EditResource(_contact.Resource);
     }
 }
コード例 #13
0
        public void TestFindEntiesWithSimplePaging(ContactDto _ContactDto)
        {
            IContactBO _ContactBO = new ContactBO(new ContactConverter());
            bool       hasAdded   = _ContactBO.CreateEntiy(_ContactDto);
            var        dbResult   = _ContactBO.FindEnties(1, 10);

            Assert.NotNull(dbResult);
            Assert.True(dbResult.Count > 0);
        }
コード例 #14
0
        public void TestFindEnties(ContactDto _ContactDto)
        {
            IContactBO _ContactBO = new ContactBO(new ContactConverter());
            bool       hasAdded   = _ContactBO.CreateEntiy(_ContactDto);
            var        dbResult   = _ContactBO.FindEnties(new PagedList <ContactDto> {
                _ContactDto
            });

            Assert.NotNull(dbResult);
            Assert.True(dbResult.Total > 0);
        }
コード例 #15
0
        public void TestGetEntiyByPK(Int32 pkid)
        {
            IContactBO _ContactBO = new ContactBO(new FakeContactConverter());
            var        dtoEntity  = new ContactDto()
            {
                ContactID = pkid
            };
            var dbResult = _ContactBO.GetEntiyByPK(dtoEntity);

            Assert.NotNull(dbResult);
        }
コード例 #16
0
        public void Delete(int id)
        {
            ContactBO contact = ContactsMap.Map(this.Contactrepository.GetContactById(id));

            if (contact == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            Contactrepository.Delete(id);
        }
コード例 #17
0
ファイル: ContactBOTests.cs プロジェクト: mo5h/omeo
        [Test] public void CheckNormilizedPhoneComparing()
        {
            string    email   = "*****@*****.**";
            ContactBO contact = (ContactBO)Core.ContactManager.FindOrCreateContact(email, "Sergey Zhulin");

            contact.SetPhoneNumber("Home", " 123-78-90");
            IResource phone = contact.GetPhoneByNumber("_1.2.3.7.8.9.0");

            Assert.IsNotNull(phone);
            Assert.AreEqual(" 123-78-90", phone.GetStringProp("PhoneNumber"));
        }
コード例 #18
0
 public IHttpActionResult CreateContact(ContactBO contact)
 {
     try
     {
         var contactId = ContactInformationService.InsertContact(contact);
         return(Ok(contactId));
     }
     catch (InvalidContactException ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #19
0
ファイル: ContactBOTests.cs プロジェクト: mo5h/omeo
        [Test] public void CreationContactBodyTest()
        {
            string    displayName = "'Sergey Zhulin'";
            ContactBO contact     = (ContactBO)_contactManager.FindOrCreateContact(null, displayName);

            contact.Birthday = new DateTime(1972, 07, 26);
            contact.Company  = "JetBrains";
            contact.HomePage = "www.jetbrains.ru";
            contact.JobTitle = "Developer";
            contact.Address  = "Sertolovo";
            Assert.AreEqual("Sergey Zhulin Sertolovo JetBrains Developer www.jetbrains.ru", contact.ContactBody);
        }
コード例 #20
0
ファイル: PhoneBlock.cs プロジェクト: mo5h/omeo
        public override void EditResource(IResource contact)
        {
            _contact = new ContactBO(contact);
            string[] phonesNames = _contact.GetPhoneNames();
            foreach (HashMap.Entry e in _phoneControls)
            {
                ((Label)e.Key).Tag = false;    //  set unused
            }
            _origPhones.Clear();

            //  Display the list of phones. Two conditions are to be satisfied:
            //  1. Three standard phone labels: "Home", "Mobile" and "Work"
            //     must be present independently of their content
            //  2. Order of the phone labels above must be kept.
            AddPhone("Home", (Array.IndexOf(phonesNames, "Home") == -1) ? "" : _contact.GetPhoneNumber("Home"), false);
            AddPhone("Mobile", (Array.IndexOf(phonesNames, "Mobile") == -1) ? "" : _contact.GetPhoneNumber("Mobile"), false);
            AddPhone("Work", (Array.IndexOf(phonesNames, "Work") == -1) ? "" : _contact.GetPhoneNumber("Work"), false);
            foreach (string name in phonesNames)
            {
                _origPhones[name] = _contact.GetPhoneNumber(name);
                if (name != "Home" && name != "Mobile" && name != "Work")
                {
                    AddPhone(name, _contact.GetPhoneNumber(name), false);
                }
            }

            //  Remove all phone controls from previous "EditResource".
            //  Thus we remove only unused phones => reduce flickering.
            bool      changed  = false;
            ArrayList toRemove = new ArrayList();

            foreach (HashMap.Entry e in _phoneControls)
            {
                if ((bool)((Label)e.Key).Tag == false)
                {
                    changed = true;
                    Controls.Remove((Label)e.Key);
                    Controls.Remove((Control)e.Value);
                    toRemove.Add((Label)e.Key);
                }
            }
            foreach (Label label in toRemove)
            {
                _phoneControls.Remove(label);
            }

            if (changed)
            {
                RedrawPhones();
            }
            UpdateHeight();
        }
        /// <summary>
        /// Update contact
        /// </summary>
        /// <param name="contact">Contact to be updated</param>
        public void UpdateContact(ContactBO contact)
        {
            if (!ContactExists(contact.Id))
            {
                throw new ContactNotFoundException();
            }

            ValideContactData(contact);

            var contactDO = ContactConverter.FromBOToDO(contact);

            ContactInformationDataManager.UpdateContact(contactDO);
        }
コード例 #22
0
ファイル: ContactsPlugin.cs プロジェクト: mo5h/omeo
        bool IResourceTextProvider.ProcessResourceText(IResource res, IResourceTextConsumer consumer)
        {
            string body = new ContactBO(res).ContactBody;

            if (body != null)
            {
                lock ( consumer )
                {
                    consumer.AddDocumentFragment(res.Id, body);
                }
            }
            return(true);
        }
コード例 #23
0
        public HttpResponseMessage Put(int id, ContactBO contact)
        {
            contact.Id = id;
            var entity = ContactsMap.Map(contact);

            if (!Contactrepository.Update(entity))
            {
                throw new HttpResponseException(HttpStatusCode.NotModified);
            }
            else
            {
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
        }
コード例 #24
0
ファイル: ContactVM.cs プロジェクト: nathantownsend/myCoal
        public ContactVM(ContactBO BO)
        {
            this.ContactID = BO.Contact.ContactID;
            this.ContactTypeID = BO.Contact.ContactTypeID;
            this.ContactClassID = BO.Contact.ContactClassID;
            this.PermitKey = BO.Contact.PermitKey;
            this.SalutationID = BO.Contact.SalutationID;
            this.FirstName = BO.Contact.FirstName;
            this.LastName = BO.Contact.LastName;
            this.CompanyName = BO.Contact.CompanyName;
            this.Title = BO.Contact.Title;
            this.TaxID = BO.Contact.TaxID;
            this.Phone = BO.Contact.Phone;
            this.PhoneExtension = BO.Contact.PhoneExtension;
            this.Fax = BO.Contact.Fax;
            this.Email = BO.Contact.Email;
            this.LegalEntityID = BO.Contact.LegalEntityID;
            this.LegalStructureDescription = BO.Contact.LegalStructureDescription;
            this.DateOfIncorporation = BO.Contact.DateOfIncorporation;
            this.StateOfIncorporationID = BO.Contact.StateOfIncorporationID;
            this.AddressID1 = BO.Addresses[0].AddressID;
            this.Address11 = BO.Addresses[0].Address1;
            this.Address12 = BO.Addresses[0].Address2;
            this.AddressTypeID1 = BO.Addresses[0].AddressTypeID;
            this.POBox1 = BO.Addresses[0].POBox;
            this.City1 = BO.Addresses[0].City;
            this.StateID1 = BO.Addresses[0].StateID;
            this.ZipCode1 = BO.Addresses[0].Zipcode;
            this.ResponsibleParty = BO.Contact.ResponsiblePartyForAbandonedMineReclamationFee;

            if (BO.Addresses.Count > 1)
            {
                this.AddressID2 = BO.Addresses[1].AddressID;
                this.Address21 = BO.Addresses[1].Address1;
                this.Address22 = BO.Addresses[1].Address2;
                this.AddressTypeID2 = BO.Addresses[1].AddressTypeID;
                this.POBox2 = BO.Addresses[1].POBox;
                this.City2 = BO.Addresses[1].City;
                this.StateID2 = BO.Addresses[1].StateID;
                this.ZipCode2 = BO.Addresses[1].Zipcode;
            }

            SetupSalutationDropdown();
            SetupState1Dropdown();
            SetupState2Dropdown();
            SetupState3Dropdown();
            SetupLegalEntities();
        }
コード例 #25
0
        public int AddContactUS(ContactBO bo)
        {
            string ConnectionString = "Data Source=ingnrilpsql02;" + "Initial Catalog=AHD13_AMS60;" + "User id=a36;" + "Password=a36;";

            SqlConnection connection = new SqlConnection(ConnectionString);
            //Connection is opened using Open method

            //create command object
            SqlCommand command = new SqlCommand();

            //Set command type as stored procedure
            command.CommandType = CommandType.StoredProcedure;
            //Command text is stored procedure name if command type is stored

            command.CommandText = "sp_Group4EnterContactUs";
            //Used to relate command object to connection
            command.Connection = connection;
            //Used to pass parameter to procedure
            command.Parameters.AddWithValue("@name", bo.name);
            command.Parameters.AddWithValue("@email", bo.email);
            command.Parameters.AddWithValue("@msg", bo.msg);

            try
            {
                connection.Open();
                int rowAffected = command.ExecuteNonQuery();
                if (rowAffected > 0)
                {
                    return(1);
                }
                else
                {
                    //returntype = false;
                    return(rowAffected);
                }
            }
            catch (SqlException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                command.Dispose();
                connection.Dispose();
                connection.Close();
            }
            return(0);
        }
コード例 #26
0
ファイル: ContactService.cs プロジェクト: karlfrank/project1
 public static ObservableCollection <ContactBO> GetPersonContacts(Person a)
 {
     using (ElibriumEntities db = new ElibriumEntities())
     {
         var Contacts = db.Contact.Where(x => x.PersonId == a.Id);
         ObservableCollection <ContactBO> ccs = new ObservableCollection <ContactBO>();
         if (Contacts.Count() > 0)
         {
             foreach (var clc in Contacts)
             {
                 ContactBO cc = new ContactBO(clc);
                 ccs.Add(cc);
             }
         }
         return(ccs);
     }
 }
コード例 #27
0
        public static ContactDO FromBOToDO(ContactBO contactBO)
        {
            if (contactBO == null)
            {
                return(null);
            }

            return(new ContactDO
            {
                Id = contactBO.Id,
                FirstName = contactBO.FirstName,
                LastName = contactBO.LastName,
                PhoneNumber = contactBO.PhoneNumber,
                Email = contactBO.Email,
                IsActive = (!string.IsNullOrEmpty(contactBO.Status) && contactBO.Status.Equals(Constants.Active, System.StringComparison.InvariantCultureIgnoreCase)) ? true : false
            });
        }
コード例 #28
0
        public PublicCopyOfApplicationVM(ContactBO BO)
        {
            this.ContactID = BO.Contact.ContactID;
            this.ContactTypeID = BO.Contact.ContactTypeID;
            this.PermitKey = BO.Contact.PermitKey;
            this.NameOfPublicOffice = BO.Contact.NameOfPublicOffice;
            this.AddressID = BO.Addresses[0].AddressID;
            this.Address11 = BO.Addresses[0].Address1;
            this.Address12 = BO.Addresses[0].Address2;
            this.AddressTypeID = BO.Addresses[0].AddressTypeID;
            this.POBox = BO.Addresses[0].POBox;
            this.City = BO.Addresses[0].City;
            this.StateID = BO.Addresses[0].StateID;
            this.ZipCode = BO.Addresses[0].Zipcode;

            SetupAddressTypeDropdown();
            SetupStateDropdown();
        }
コード例 #29
0
ファイル: HomeController.cs プロジェクト: tuanpm212/atmtns123
        public ActionResult Contact(Contact model)
        {
            ContactBO _contact = new ContactBO();
                if (model != null)
                {
                    model.CreatedDate = DateTime.Now;
                    if (_contact.Add(model))
                    {
                        string body = string.Format(Resources.EmailTemplate.feedbackBody, model.UserName);
                        this.SendEmailMessage(model.Email, Resources.EmailTemplate.feedbackSubject, Resources.EmailTemplate.feedbackBody);

                        body = string.Format(Resources.EmailTemplate.fromBody, model.UserName, model.Email, model.Title, model.Content);
                        this.SendEmailMessage(model.Email, Resources.EmailTemplate.fromSubject, body);

                        this.ModelState.Clear();
                        model = new Contact();
                    }
                }
                return View(model);
        }
コード例 #30
0
 public IHttpActionResult UpdateContact(ContactBO contact)
 {
     if (contact == null)
     {
         return(BadRequest("Contact cannot be null"));
     }
     try
     {
         ContactInformationService.UpdateContact(contact);
     }
     catch (ContactNotFoundException)
     {
         return(NotFound());
     }
     catch (InvalidContactException ex)
     {
         return(BadRequest(ex.Message));
     }
     return(Ok());
 }
コード例 #31
0
        public ActionResult Contact(Contact model)
        {
            ContactBO _contact = new ContactBO();

            if (model != null)
            {
                model.CreatedDate = DateTime.Now;
                if (_contact.Add(model))
                {
                    string body = string.Format(Resources.EmailTemplate.feedbackBody, model.UserName);
                    this.SendEmailMessage(model.Email, Resources.EmailTemplate.feedbackSubject, Resources.EmailTemplate.feedbackBody);

                    body = string.Format(Resources.EmailTemplate.fromBody, model.UserName, model.Email, model.Title, model.Content);
                    this.SendEmailMessage(model.Email, Resources.EmailTemplate.fromSubject, body);

                    this.ModelState.Clear();
                    model = new Contact();
                }
            }
            return(View(model));
        }
コード例 #32
0
ファイル: PhoneBlock.cs プロジェクト: mo5h/omeo
        public override string  HtmlContent(IResource contact)
        {
            string result = string.Empty;

            ContactBO bo = new ContactBO(contact);

            string[] phoneNames = bo.GetPhoneNames();

            result += AddPhoneText("Home", phoneNames, bo);
            result += AddPhoneText("Mobile", phoneNames, bo);
            result += AddPhoneText("Work", phoneNames, bo);

            foreach (string phoneName in phoneNames)
            {
                if (phoneName != "Home" && phoneName != "Mobile" && phoneName != "Work")
                {
                    result += "\t<tr><td>" + phoneName + "</td><td>" + bo.GetPhoneNumber(phoneName) + "</td></tr>";
                }
            }
            return(result);
        }
コード例 #33
0
 private void btnAddContact_Click(object sender, RoutedEventArgs e)
 {
     if (_vm.ContactTypes.Count > 0)
     {
         if (!contactValueBox.Text.Equals(""))
         {
             PersonBO      a           = lvPersons.SelectedItem as PersonBO;
             ContactTypeBO contactType = cBoxContactTypes.SelectedItem as ContactTypeBO;
             if (a != null)
             {
                 ContactBO cbo = new ContactBO(contactValueBox.Text, (lvPersons.SelectedItem as PersonBO).Id, (cBoxContactTypes.SelectedItem as ContactTypeBO).Id);
                 if (contactType.Name.Equals("Email"))
                 {
                     if (!IsValid(contactValueBox.Text))
                     {
                         MessageBoxResult result = MessageBox.Show("The email is invalid, aborting", "Warning", MessageBoxButton.OK);
                         return;
                     }
                 }
                 cbo.AddOrUpdate();
                 this._vm._contacts     = a.Contacts;
                 lvContacts.ItemsSource = _vm.Contacts;
                 lvContacts.UpdateLayout();
             }
             else
             {
                 MessageBox.Show("Select a Person first, to whom you want to add the contact", "A big fat warning", MessageBoxButton.OK);
             }
         }
         else
         {
             MessageBox.Show("Contact value can not be empty", "Warning", MessageBoxButton.OK);
         }
     }
     else
     {
         MessageBox.Show("Add atleast one contact type first", "Warning", MessageBoxButton.OK);
     }
     e.Handled = true;
 }
コード例 #34
0
ファイル: ContactBOTests.cs プロジェクト: mo5h/omeo
        [Test] public void CreationContactBodyTest2()
        {
            string    displayName = "'Sergey Zhulin'";
            ContactBO contact     = (ContactBO)_contactManager.FindOrCreateContact(null, displayName);

            Assert.AreEqual(false, contact.Changed);

            int id = contact.Resource.Id;

            contact.Birthday = new DateTime(1972, 07, 26);
            contact.Company  = "JetBrains";
            contact.HomePage = "www.jetbrains.ru";
            contact.JobTitle = "Developer";
            contact.Address  = "Sertolovo";
            Assert.AreEqual(true, contact.Changed);
//            contact.Save();
            Assert.AreEqual(id, contact.ID);

            contact = (ContactBO)_contactManager.FindOrCreateContact(null, displayName);
            Assert.AreEqual(false, contact.Changed);
            Assert.AreEqual("Sergey Zhulin Sertolovo JetBrains Developer www.jetbrains.ru", contact.ContactBody);
            Assert.AreEqual(id, contact.ID);
        }
コード例 #35
0
        public HttpResponseMessage Post(ContactBO request)
        {
            var data = ContactsMap.Map(request);

            var entity   = Contactrepository.Insert(data);
            var response = Request.CreateResponse(HttpStatusCode.Created, entity);

            try
            {
                string uri = Url.Link("DefaultApi", new { id = entity.ID });
                response.Headers.Location = new Uri(uri);
            }
            catch (Exception e)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content      = new StringContent("An error occurred, please try again"),
                    ReasonPhrase = "Critical exception"
                });
            }

            return(response);
        }