private Guid UpdateContact(CustomerContactModel model) { var _noteId = SaveNote(model); var item = _contactService.Find(model.ContactID); item.FirstName = model.FirstName; item.LastName = model.LastName; item.Title = model.Title; item.ContactType = model.ContactType; item.ContactReference = model.ContactReference; item.EmailAddress = model.EmailAddress; item.DDITelephoneNo = model.DDITelephoneNo; item.MobileNo = model.MobileNo; item.NoteID = _noteId; item.ObjectState = ObjectState.Modified; _contactService.Update(item); return(item.ContactID); }
/// <summary> /// View customer's information /// </summary> /// <param name="id">id of customer</param> /// <returns></returns> public ActionResult ViewDetail(int id = 0) { //variables crm_Countries country = null; CustomerContactModel model = null; model = _customerService.GetCustomerInfor(id); if (model == null) { return(RedirectToAction("Index")); } country = _countryService.GetCountryById(model.CountryId.HasValue?model.CountryId.Value:0); model.CountryName = country == null ? "" : country.CountryName; return(View(model)); }
private Guid?SaveNote(CustomerContactModel model) { if (string.IsNullOrEmpty(model.NoteDescription)) { model.NoteDescription = "?!"; // <--- Paul Edwards } if (!string.IsNullOrEmpty(model.Notes)) { if (model.NoteID == null || model.NoteID == Guid.Empty) { model.NoteID = CreateNote(model); } else { model.NoteID = UpdateNote(model); } } return(model.NoteID); }
private Guid CreateContact(CustomerContactModel model) { var _noteId = SaveNote(model); var _obj = new Contact { ContactID = PrimeActs.Service.IDGenerator.NewGuid(_serverCode[0]), FirstName = model.FirstName, LastName = model.LastName, Title = model.Title, ContactType = model.ContactType, ContactReference = model.ContactReference, EmailAddress = model.EmailAddress, DDITelephoneNo = model.DDITelephoneNo, MobileNo = model.MobileNo, NoteID = _noteId, ObjectState = ObjectState.Added }; _contactService.Insert(_obj); return(_obj.ContactID); }
public CustomerContactModel AddCustomerContact(CustomerContactModel recordToAdd) { using (var model = new gb_ts_stagingEntities()) { var newRecord = new CustomerContact { EMail = recordToAdd.EMail, CustomerId = recordToAdd.CustomerId, Priority = recordToAdd.Priority, FirstName = recordToAdd.FirstName ?? "", LastName = recordToAdd.LastName ?? "", Phones = recordToAdd.Phones ?? "", Skype = recordToAdd.Skype ?? "", UserId = recordToAdd.UserId ?? "" }; model.CustomerContacts.Add(newRecord); model.SaveChanges(); recordToAdd.Id = newRecord.Id; return(recordToAdd); } }
public CustomerContactModel FindCustomerContactModel(int id, CompanyModel company, int customerId, bool bCreateEmptyIfNotfound = true) { CustomerContactModel model = null; var a = db.FindCustomerContact(id); if (a == null) { if (bCreateEmptyIfNotfound) { model = new CustomerContactModel { CompanyId = company.Id, CustomerId = customerId } } ; } else { model = MapToModel(a); } return(model); }
public void SetCustomerContactModel(int customerId, CustomerContactModel customerContactModel) { var settingFactory = new SettingsFactory(); if (customerContactModel.FirstName != null) { settingFactory.Set(customerId, "CustomerContactFirstName", customerContactModel.FirstName); } if (customerContactModel.LastName != null) { settingFactory.Set(customerId, "CustomerContactLastName", customerContactModel.LastName); } if (customerContactModel.FromEmailAddress != null) { settingFactory.Set(customerId, "CustomerContactEMail", customerContactModel.FromEmailAddress); } if (customerContactModel.PhoneNumber != null) { settingFactory.Set(customerId, "CustomerContactPhoneNumber", customerContactModel.PhoneNumber); } }
private Error BuildRecipientLists(string selectedIds, CustomerContactModel contact, CompanyModel company, CustomerModel customer, bool bSaveAsContact, List <UserModel> toUsers, List <UserModel> ccUsers) { // SelectedIds is supplied as a comma separated list: // To:123,CC:-345,To:OTH // Where: // A prefix of 'To' denotes a recipient // A prefix of 'Cc' denotes a user to 'cc' to // A positive number represents an id of a CustomerContact record // A negative number represents the id of a User record (multiply it by -1 to get the positive value) // OTH indicates that the details for 'Other User' should be retrieved from parameter: contact // The method returns two lists of UserModels, one for 'To' and one for 'cc' recipients. var error = new Error(); var selected = selectedIds.ToLower().Split(','); foreach (var recipient in selected) { var pos = recipient.IndexOf(":"); if (pos != -1) { UserModel user = null; var recType = recipient.Substring(0, pos).ToLower(); var recId = recipient.Substring(pos + 1).ToLower(); if (recId == "oth") { // New contact if (bSaveAsContact) { contact.CompanyId = company.Id; contact.Enabled = true; error = CustomerService.InsertOrUpdateCustomerContact(contact, user, ""); } else { error = CustomerService.ValidateContactModel(contact); } if (error.IsError) { break; } else { user = new UserModel { FirstName = contact.ContactFirstname, LastName = contact.ContactSurname, EMail = contact.ContactEmail }; } } else { var id = Convert.ToInt32(recId); if (Convert.ToInt32(id) < 0) { // User user = MembershipManagementService.FindUserModel(Math.Abs(id)); } else { // Contact var temp = CustomerService.FindCustomerContactModel(id, company, customer, false); if (temp != null) { user = new UserModel { FirstName = temp.ContactFirstname, LastName = temp.ContactSurname, EMail = temp.ContactEmail } } ; } } if (user != null) { if (recType == "to") { toUsers.Add(user); } else { ccUsers.Add(user); } } } } return(error); } }
CustomerMarketingModel createCustomerMarketing(int companyId, int customerId, UserModel user, CustomerContactModel contact) { var group = LookupService.FindMarketingGroupsListModel(companyId, 0, 1, 100, "").Items.First(); CustomerMarketingModel model = new CustomerMarketingModel { CompanyId = companyId, CustomerId = customerId, CustomerContactId = contact.Id, ContactName = (contact.ContactFirstname + " " + contact.ContactSurname).Trim(), MarketingGroupId = group.Id, GroupName = group.MarketingGroupName }; var error = CustomerService.InsertOrUpdateCustomerMarketing(model, user, ""); Assert.IsTrue(!error.IsError, error.Message); return(model); }
public IActionResult editcustomer(string cus) { ViewData["cus_id"] = cus; CustomerModel ctm = new CustomerModel(); ctm.select_customer(" cus_id = '" + cus + "'"); ViewData["cus_code"] = ctm.cus_code; ViewData["cus_name"] = ctm.cus_name; ViewData["cus_name_contact"] = ctm.cus_name_contact; ViewData["cus_trade"] = ctm.cus_trade; ViewData["cus_tax"] = ctm.cus_tax; customerTypeModel ct = new customerTypeModel(); ViewData["cus_type"] = ct.drop_cus_type_code(ctm.cus_ref_type_id); prefixModel px = new prefixModel(); ViewData["prefix"] = px.drop_prefix(ctm.cus_ref_prefix_id); px.select_prefix("prefix_id = '" + ctm.cus_ref_prefix_id + "'"); ViewData["last_name"] = px.prefix_ending; CustomerAddressModel ca = new CustomerAddressModel(); ca.select_address("add_ref_cus_id = '" + cus + "'"); ViewData["add_num"] = ca.add_num; ViewData["add_alley"] = ca.add_alley; ViewData["add_road"] = ca.add_road; ViewData["add_postcode"] = ca.add_poscode; ViewData["add_status"] = ca.add_type_status; ViewData["add_branch"] = ca.add_branch; ViewData["add_id"] = ca.add_id; provinceModel pv = new provinceModel(); ampuresModel am = new ampuresModel(); districts dt = new districts(); ViewData["province"] = pv.drop_province(ca.add_province); ViewData["amphur"] = am.dorp_amphur(ca.add_amphur); ViewData["district"] = dt.drop_district(ca.add_district); CustomerContactModel c_t = new CustomerContactModel(); c_t.select_contact("ct_ref_cus_id = '" + cus + "'"); ViewData["ct_tel"] = c_t.ct_tel; ViewData["ct_fax"] = c_t.ct_fax; ViewData["ct_email"] = c_t.ct_email; ViewData["ct_web"] = c_t.ct_web; ViewData["ct_id"] = c_t.ct_id; CustomerCreditModel crd = new CustomerCreditModel(); crd.select_credit("credit_ref_cus_id = '" + cus + "'"); ViewData["credit_money"] = crd.credit_money; ViewData["credit_id"] = crd.credit_id; conditionPayModel cd = new conditionPayModel(); ViewData["condition"] = cd.drop_con_pay(crd.credit_ref_condition); CustomerLineSaleModel cl = new CustomerLineSaleModel(); cl.select_cus_line("cs_ref_cus_id = '" + cus + "'"); ViewData["sale_name"] = cl.cs_sale_name; ViewData["sale_id"] = cl.cs_id; lineModel ln = new lineModel(); ViewData["line"] = ln.drop_line(cl.cs_ref_line_id); line_saleModel ls = new line_saleModel(); ViewData["line_sale"] = ls.drop_line_sale(""); CustomerTransportModel ts = new CustomerTransportModel(); ts.select_cus_tran("at_ref_cus_id = '" + cus + "'"); ViewData["name_ts"] = ts.at_customer_name; ViewData["num_ts"] = ts.at_num; ViewData["alley_ts"] = ts.at_alley; ViewData["road_ts"] = ts.at_road; ViewData["postcode_ts"] = ts.at_postcode; ViewData["province_ts"] = pv.drop_province(ts.at_province); ViewData["amphur_ts"] = am.dorp_amphur(ts.at_amphur); ViewData["district_ts"] = dt.drop_district(ts.at_district); ViewData["ts_id"] = ts.at_id; return(View()); }
public IActionResult update_customer(string cus_id, string add_id, string ct_id, string credit_id, string sale_id, string ts_id, string cus_type, string cus_prefix, string cus_name, string cus_lastname, string cus_name_contact, string cus_trade, string cus_tax, string add_num, string add_alley, string add_road, string add_province, string add_amphur, string add_distict, string add_postcode, string add_type_status, string add_branch, string ct_tel, string ct_fax, string ct_email, string ct_web, string credit_money, string credit_condition, string line_sale, string name_sale, string at_customer_name, string at_num, string at_alley, string at_road, string at_province, string at_amphur, string at_district, string at_postcode) { customerTypeModel c_tp = new customerTypeModel(); c_tp.type_id = cus_type; c_tp.select_cus_type(); CustomerModel cus = new CustomerModel(); cus.cus_id = cus_id; cus.cus_ref_type_id = c_tp.type_code; cus.cus_ref_prefix_id = cus_prefix; cus.cus_name = cus_name; cus.cus_name_contact = cus_name_contact; cus.cus_trade = cus_trade; cus.cus_tax = cus_tax; cus.update_customer(); CustomerAddressModel add = new CustomerAddressModel(); add.add_id = add_id; add.add_num = add_num; add.add_alley = add_alley; add.add_road = add_road; add.add_province = add_province; add.add_amphur = add_amphur; add.add_district = add_distict; add.add_poscode = add_postcode; add.add_type_status = add_type_status; add.add_branch = add_branch; add.add_ref_cus_id = cus_id; add.update_address(); CustomerContactModel ct = new CustomerContactModel(); ct.ct_id = ct_id; ct.ct_tel = ct_tel; ct.ct_fax = ct_fax; ct.ct_email = ct_email; ct.ct_web = ct_web; ct.ct_ref_cus_id = cus_id; ct.update_contact(); CustomerCreditModel cd = new CustomerCreditModel(); cd.credit_id = credit_id; cd.credit_money = credit_money; cd.credit_ref_condition = credit_condition; cd.credit_ref_cus_id = cus_id; cd.update_credit(); CustomerLineSaleModel ls = new CustomerLineSaleModel(); ls.cs_id = sale_id; ls.cs_ref_line_id = line_sale; ls.cs_sale_name = name_sale; ls.cs_ref_cus_id = cus_id; ls.update_cus_line(); CustomerTransportModel tp = new CustomerTransportModel(); tp.at_id = ts_id; tp.at_customer_name = at_customer_name; tp.at_num = at_num; tp.at_alley = at_alley; tp.at_road = at_road; tp.at_province = at_province; tp.at_amphur = at_amphur; tp.at_district = at_district; tp.at_postcode = at_postcode; tp.at_ref_cus_id = cus_id; tp.update_cus_tran(); return(RedirectToAction("customer", "Customer", new { add = add.add_id })); }
private IEnumerable <CustomerContactModel> GetAllCustomers() { var customer_one = new CustomerContactModel { Id = 1, Title = "Mr", FirstName = "Omar", LastName = "Itani", ContactNumbers = new List <ContactNumberModel> { new ContactNumberModel { Number = "0123456789", NumberActive = true, Type = NumberType.MOBILE }, new ContactNumberModel { Number = "3456789012", NumberActive = true, Type = NumberType.WORK }, new ContactNumberModel { Number = "6789012345", NumberActive = false, Type = NumberType.HOME }, new ContactNumberModel { Number = "8901234567", NumberActive = true, Type = NumberType.OTHER } } }; var customer_two = new CustomerContactModel { Id = 2, Title = "Mrs", FirstName = "Linda", LastName = "Mason", ContactNumbers = new List <ContactNumberModel> { new ContactNumberModel { Number = "0123433389", NumberActive = false, Type = NumberType.MOBILE }, new ContactNumberModel { Number = "3456555012", NumberActive = false, Type = NumberType.WORK }, new ContactNumberModel { Number = "6789999345", NumberActive = false, Type = NumberType.HOME }, new ContactNumberModel { Number = "8901234122", NumberActive = true, Type = NumberType.OTHER } } }; var customer_three = new CustomerContactModel { Id = 3, Title = "Mr", FirstName = "Adam", LastName = "Loftus", ContactNumbers = new List <ContactNumberModel> { new ContactNumberModel { Number = "0123223389", NumberActive = false, Type = NumberType.MOBILE }, new ContactNumberModel { Number = "3454455012", NumberActive = false, Type = NumberType.WORK }, new ContactNumberModel { Number = "6889999345", NumberActive = true, Type = NumberType.HOME }, new ContactNumberModel { Number = "8901234002", NumberActive = true, Type = NumberType.OTHER } } }; return(new List <CustomerContactModel> { customer_one, customer_two, customer_three }); }
public void MapToEntity(CustomerContactModel model, CustomerContact entity) { Mapper.Map <CustomerContactModel, CustomerContact>(model, entity); }
public string LockCustomerContact(CustomerContactModel model) { return(db.LockRecord(typeof(CustomerContact).ToString(), model.Id)); }
public CustomerModel(AddressModel address, CustomerContactModel customerContact) { Address = address; CustomerContact = customerContact; }
public MaintenanceGroupIdentificationModel() { Status = new CustomerStatusModel(); Contact = new CustomerContactModel(); Localization = new CustomerLocalizationModel(); }