public void CompanyContactPrintTest() { // Arrange CompanyContact contact = new CompanyContact("1"); contact.Name = "Name 1"; contact.Address = "Address 1"; contact.PhoneNumber = "23453545434"; contact.Url = "Url"; string expectedResult = String.Format(Constants.Defaults.DefaultPrintFormat, Constants.Fields.TaxID, contact.TaxID) + String.Format(Constants.Defaults.DefaultPrintFormat, nameof(contact.Name), contact.Name) + String.Format(Constants.Defaults.DefaultPrintFormat, nameof(contact.Address), (contact.Address != null) ? contact.Address : String.Empty) + String.Format(Constants.Defaults.DefaultPrintFormat, Constants.Fields.PhoneNumber, (contact.PhoneNumber != null) ? contact.PhoneNumber : String.Empty) + String.Format(Constants.Defaults.DefaultPrintFormat, nameof(contact.Url), contact.Url) + String.Format(Constants.Defaults.DefaultPrintFormat, Constants.Fields.ModifiedDate, contact.ModifiedDate.ToString(Constants.Defaults.DateFormat)) + String.Format(Constants.Defaults.DefaultPrintFormat, Constants.Fields.CreatedDate, contact.CreatedDate.ToString(Constants.Defaults.DateFormat)); // act string actualResult = contact.ToString(); // asset StringAssert.Equals(actualResult, expectedResult); }
public virtual IEnumerable <Contact> GetAllByOrganizationId(Guid organizationId) { CompanyContact companyContact = null; var queryOver = new QueryOverContact().GetQueryOver().JoinQueryOver(x => x.CompanyContacts, () => companyContact).Where(() => companyContact.Company.OrganizationId == organizationId); return(this.Repository.FindAll(queryOver)); }
public void RepositoryTest_Update_Company_Success() { //Arrange var dateTime = DateTime.Now; CompanyContact wc = ((CompanyContact)FakeDataFactory.Get <CompanyContact>( taxId: 1, name: "Name1", address: "address11", phoneNumber: "000000001", url: "www.url1.com" )); var contactsDto = new List <ContactDto>() { FakeDataFactory.GetDto <CompanyDto>() }; var repository = new ContactRepository(contactsDto); //Act repository.Update(wc, 1); //Assert Assert.AreEqual(contactsDto.Count, 1); Assert.IsInstanceOfType(contactsDto[0], typeof(CompanyDto)); Assert.AreEqual(contactsDto[0].Address, wc.Address); Assert.AreEqual(contactsDto[0].Name, wc.Name); Assert.AreEqual(contactsDto[0].PhoneNumber, wc.PhoneNumber); Assert.AreEqual(contactsDto[0].TaxId, wc.TaxId); Assert.AreEqual(((CompanyDto)contactsDto[0]).Url, wc.Url); }
/// <summary> /// 修改 /// </summary> public override void EntityUpdate() { CompanyContactRule rule = new CompanyContactRule(); CompanyContact entity = EntityGet(); rule.RUpdate(entity); }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { CompanyContact MasterEntity = (CompanyContact)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Data_CompanyContact WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(Sql); } else { AffectedRows = sqlTrans.ExecuteNonQuery(Sql); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E); } }
public void MapperTest_ContactToContactDto_CompanyContact() { //Arrange //Act CompanyContact cc = new CompanyContact() { TaxId = 1, Name = "Name", DateCreated = new DateTime(), DateModified = new DateTime(), PhoneNumber = "999-999-9999", Address = "Address", Url = "www.url.com" }; ContactDto cDto = ((Contact)cc).ToContactDto(); //Assert Assert.IsInstanceOfType(cDto, typeof(CompanyDto)); Assert.AreEqual(cDto.Name, cc.Name); Assert.AreEqual(cDto.TaxId, cc.TaxId); Assert.AreEqual(cDto.DateCreated, cc.DateCreated); Assert.AreEqual(cDto.DateModified, cc.DateModified); Assert.AreEqual(((CompanyDto)cDto).Url, cc.Url); Assert.AreEqual(cDto.PhoneNumber, cc.PhoneNumber); Assert.AreEqual(cDto.Address, cc.Address); }
/// <summary> /// The get all for user. /// </summary> /// <param name="userId"> /// The user id. /// </param> /// <returns> /// The <see cref="IEnumerable{Company}"/>. /// </returns> public IEnumerable <Company> GetAllForUser(int userId) { CompanyContact companyContact = null; var query = new DefaultQueryOver <Company, int>().GetQueryOver().JoinQueryOver(x => x.CompanyContacts, () => companyContact).Where(() => companyContact.Contact.Id == userId); return(this.Repository.FindAll(query)); }
private void btnFinish_Click(object sender, EventArgs e) { //fill CompanyContact Object temp.companyId = owningCompany.Id; temp.salutation = txtSalutation.Text; temp.firstName = txtFirstName.Text; temp.lastName = txtLastName.Text; temp.title = txtTitle.Text; temp.branchId = txtBranchId.Text; temp.extension = txtExt.Text; temp.title = txtTitle.Text; temp.signature = txtSignature.Text; //add/update object to Global contacts list -> instead of DB for now if (editing == true) { //replace CompanyContact.updateCompanyContact(temp); } else { //add //Globals.contacts.Add(newContact); CompanyContact.insertCompanyContact(temp); } //return to Cx portal CustomerPortalScreen cp = new CustomerPortalScreen(); cp.MdiParent = this.MdiParent; cp.Show(); this.Close(); }
public async Task <CompanyContact> AddCompanyContact(CompanyContact companyContact) { var newContact = _db.CompanyContacts.Add(companyContact); await _db.SaveChangesAsync(); return(newContact.Entity); }
public void MapperTest_CompanyDtoToCompanyContact() { //Arrange //Act CompanyDto cDto = new CompanyDto() { TaxId = 1, Name = "Name", DateCreated = new DateTime(), DateModified = new DateTime(), PhoneNumber = "999-999-9999", Address = "Address", Url = "www.url.com" }; CompanyContact cc = cDto.ToCompanyContact(); //Assert Assert.AreEqual(cc.Name, cDto.Name); Assert.AreEqual(cc.TaxId, cDto.TaxId); Assert.AreEqual(cc.DateCreated, cDto.DateCreated); Assert.AreEqual(cc.DateModified, cDto.DateModified); Assert.AreEqual(cc.Url, cDto.Url); Assert.AreEqual(cc.PhoneNumber, cDto.PhoneNumber); Assert.AreEqual(cc.Address, cDto.Address); }
public override void Load(AppointmentFormController appointmentController) { base.Load(appointmentController); SetEditorTypeFor(m => m.Subject, DialogFieldEditorType.ComboBox); SetDataItemsFor(m => m.Subject, (addItemDelegate) => { addItemDelegate("meeting", "meeting"); addItemDelegate("travel", "travel"); addItemDelegate("phone call", "phonecall"); }); List <Company> companies = Company.GenerateCompanyDataSource(); SetDataItemsFor((CustomAppointmentEditDialogViewModel m) => m.AppointmentCompany, (addItemDelegate) => { foreach (Company comp in companies) { addItemDelegate(comp.CompanyName, comp.CompanyID); } }); SetDataItemsFor((CustomAppointmentEditDialogViewModel m) => m.AppointmentContact, (addItemDelegate) => { List <CompanyContact> contacts = CompanyContact.GenerateContactDataSource().Where(c => c.CompanyID == AppointmentCompany).ToList(); addItemDelegate("", 0); foreach (CompanyContact cont in contacts) { addItemDelegate(cont.ContactName, cont.ContactID); } }); TrackPropertyChangeFor((CustomAppointmentEditDialogViewModel m) => m.AppointmentCompany, () => { AppointmentContact = 0; }); TrackPropertyChangeFor(m => m.Subject, () => { });// just to process changing via server to show/hide company/contact }
public static Result <RecruitingCompany> Create( ObjectId userId, string socialName, string businessName, string cnpj, Address address, CompanyContact hrResponsible, CompanyContact opResponsible, long?companySize, string businessActivity, long?yearlyHiring, string profileMeasuringtool, bool authLogo, string logoUrl ) { return(Result.Ok( new RecruitingCompany() { Id = ObjectId.GenerateNewId(), CreatedBy = userId, SocialName = socialName, BusinessName = businessName, Cnpj = cnpj, Address = address, HumanResourcesResponsible = hrResponsible, OperationsResponsible = opResponsible, CompanySize = companySize, BusinessActivity = businessActivity, YearlyHiring = yearlyHiring, ProfileMeasuringTool = profileMeasuringtool, AuthLogo = authLogo, LogoUrl = logoUrl } )); }
/// <summary> /// 新增 /// </summary> public override int EntityAdd() { CompanyContactRule rule = new CompanyContactRule(); CompanyContact entity = EntityGet(); rule.RAdd(entity); return(entity.ID); }
public CompanyContactScreen(int compId) { InitializeComponent(); owningCompany = Company.getCompanyById(compId); grpContactHeader.Text = "Add New " + owningCompany.companyName + " Contact: "; temp = new CompanyContact(); editing = false; }
public CompanyContactScreen(Company comp) { InitializeComponent(); grpContactHeader.Text = "Add New " + comp.companyName + " Contact: "; temp = new CompanyContact(); owningCompany = comp; editing = false; }
/// <summary> /// Initializes a new instance of the <see cref="CompanyContactDTO"/> class. /// </summary> /// <param name="cc"> /// The CompanyContact. /// </param> public CompanyContactDTO(CompanyContact cc) { if (cc != null) { this.companyId = cc.Company.With(x => x.Id); this.contactTypeId = cc.ContactType.With(x => x.Id); } }
public bool DeleteCompanyContact(int contactId) { CompanyContact cont = _context.CompanyContacts.FirstOrDefault(x => x.ContactID == contactId); _context.CompanyContacts.Remove(cont); _context.SaveChanges(); return(true); }
public ActionResult DeleteConfirmed(int id) { CompanyContact companyContact = db.CompanyContacts.Find(id); db.CompanyContacts.Remove(companyContact); db.SaveChanges(); return(RedirectToAction("Index")); }
public static Company CreateCompany(AccountSvc _accountSvc, int accountId, bool isSST = false) { var companyContact = new CompanyContact { CompanyContactCode = "001", FirstName = "testfirstname", LastName = "testlastname", Line1 = "700 Pike St", City = "Seattle", Region = "WA", PostalCode = "98101", Phone = "1-877-780-4848", Email = "*****@*****.**", CreatedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow }; var company = new Company { AccountId = accountId, CompanyCode = Guid.NewGuid().ToString("N").Substring(0, 25), CompanyName = "TEST::" + Guid.NewGuid().ToString("N"), CompanyId = 0, IsActive = true, HasProfile = true, IsReportingEntity = true, CreatedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, RoundingLevelId = RoundingLevelId.Document, DefaultCountry = "US", IsTest = false, TaxDependencyLevelId = TaxDependencyLevelId.Document, IsDefault = false, TIN = "123457777" }; if (isSST) { company.SSTEffDate = DateTime.UtcNow.AddYears(-10); company.SSTPID = "Test"; } company.Contacts.Add(companyContact); CompanySaveResult result = _accountSvc.CompanySave(company); if (result.ResultCode != SeverityLevel.Success) { foreach (Message message in result.Messages) { Console.WriteLine(message.Summary); } return(null); } company.CompanyId = result.CompanyId; return(company); }
public CompanyContactScreen(Company comp, CompanyContact contact, bool edIn) { InitializeComponent(); grpContactHeader.Text = "Add New " + comp.companyName + " Contact: "; temp = new CompanyContact(); owningCompany = comp; temp = contact; editing = edIn; }
public void DiscoverEntitySetInheritance() { using (var uow = new TestDbContext(_connection)) { var c = new CompanyContact(); var set = ((IObjectContextAdapter)uow).ObjectContext.TryGetEntitySet(c); Assert.IsNotNull(set); } }
public ActionResult Edit([Bind(Include = "Id,Name,Phone,Email,Fax,CompanyId")] CompanyContact companyContact) { if (ModelState.IsValid) { db.Entry(companyContact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CompanyId = new SelectList(db.Companies, "Id", "Name", companyContact.CompanyId); return(View(companyContact)); }
private bool FindContacts(CompanyContact contact) { if (contact.companyId == this.companyId) { return(true); } else { return(false); } }
private void cboUpdateContact_SelectedIndexChanged(object sender, EventArgs e) { try { string s = cboUpdateContact.SelectedValue.ToString(); contactId = Convert.ToInt32(s); contact = CompanyContact.getContactById(contactId); } catch (Exception) { } }
private void ContactPortalScreen_Load(object sender, EventArgs e) { //companyId = owningCompany.companyId; //List<CompanyContact> compContacts; //compContacts = Globals.contacts.FindAll(FindContacts); //fill combo list with global contacts list cboUpdateContact.DataSource = CompanyContact.getAllCompanyContacts(); cboUpdateContact.DisplayMember = "firstName"; cboUpdateContact.ValueMember = "id"; }
private void btnDeleteContact_Click(object sender, EventArgs e) { //Globals.contacts.RemoveAt(contactId); CompanyContact.deleteCompanyContact(contactId); MessageBox.Show("Contact Deleted"); ContactPortalScreen cp = new ContactPortalScreen(owningCompany); cp.MdiParent = this.MdiParent; cp.Show(); this.Close(); }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { CompanyContact MasterEntity = (CompanyContact)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Data_CompanyContact("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("CompanyID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.CompanyID) + ","); MasterField.Append("DepID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DepID) + ","); MasterField.Append("Tel" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Tel) + ","); MasterField.Append("Fax" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Fax) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("DelFlag" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ")"); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E); } }
public JsonResult SaveCompanyContact(CompanyContact contact) { NameValueCollection errors = new NameValueCollection(); var res = new CompanyRepository().SaveCompanyContact(contact, User.UserId); ViewBag.Message = "Changes have been saved"; return(Json(new { Success = errors.Count == 0 //, //Errors = (ModelState.IsValid ? null : ModelState.Errors()) }, JsonRequestBehavior.AllowGet)); }
// GET: Customer/CompanyContacts/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompanyContact companyContact = db.CompanyContacts.Find(id); if (companyContact == null) { return(HttpNotFound()); } return(View(companyContact)); }
public bool SaveCompanyContact(CompanyContact contact, int userId) { //first, save Address int addrId = 0; Address addrOld = _context.Addresses.FirstOrDefault(x => x.AddressID == contact.Address.AddressID); if (addrOld == null) //new Address { Address addrNew = contact.Address; _context.Addresses.Add(addrNew); _context.SaveChanges(); addrId = addrNew.AddressID; } else { addrOld.Addr1 = contact.Address.Addr1; addrOld.Addr2 = contact.Address.Addr2; addrOld.City = contact.Address.City; addrOld.State = contact.Address.State; addrOld.Country = contact.Address.Country; addrOld.PostalCode = contact.Address.PostalCode; _context.SaveChanges(); } CompanyContact contOld = _context.CompanyContacts.FirstOrDefault(x => x.ContactID == contact.ContactID); if (contOld == null) { contOld = contact; contOld.ModifiedDate = DateTime.Now; contOld.ModifiedBy = userId; _context.CompanyContacts.Add(contOld); _context.SaveChanges(); } else { contOld.Suffix = contact.Suffix; contOld.FirstName = contact.FirstName; contOld.MidName = contact.MidName; contOld.LastName = contact.LastName; contOld.eMail = contact.eMail; contOld.Phone1 = contact.Phone1; contOld.Phone2 = contact.Phone2; contOld.ModifiedBy = userId; contOld.ModifiedDate = DateTime.Now; contOld.RoleId = contact.RoleId; _context.SaveChanges(); } return(true); }
//Creates a new company in the target account with hardcoded company detail. private static int CreateNewCompany(AccountSvc svc, int accountId) { //check credentials by pulling current account data FetchRequest req = new FetchRequest(); req.Filters = "AccountId=" + accountId; CompanyFetchResult fetchres = svc.CompanyFetch(req); Console.WriteLine("Companies fetched: "+ fetchres.RecordCount); Company company = new Company(); company.AccountId = accountId; company.CompanyCode = "XYZ"+DateTime.Now; //This will need to be unique on the account - it should be whatever unique system value you assign to the merchant. company.CompanyName = "Test Company XYZ"; //Does not need to be strictly unique - should be the legal name of the merchant. CompanyContact company_contact = new CompanyContact(); //This should be the contact info for your primary contact at the merchant company. company_contact.CompanyContactCode = "001"; company_contact.FirstName = "Anya"; company_contact.LastName = "Stettler"; company_contact.Line1 = "100 Ravine Lane"; company_contact.City = "Bainbridge Island"; company_contact.Region = "WA"; company_contact.PostalCode = "98110"; company_contact.Phone = "1-877-780-4848"; company_contact.Email = "*****@*****.**"; CompanyContact[] arr = new CompanyContact[1]; arr[0] = company_contact; company.Contacts = arr; company.IsActive = true; // Allow us to skip activiation later. company.HasProfile = true; //Tells us that you will be creating a tax profile for this company instead of inheriting an existing one. company.IsReportingEntity = true; //Separates reported transctions from other companies. CompanySaveResult res = new CompanySaveResult(); try { res = svc.CompanySave(company); //Save the company if (res.ResultCode.Equals(SeverityLevel.Success)) { Console.WriteLine("Company saved successfully. CompanyId: " + res.CompanyId); } else { Console.WriteLine("Error when saving company. Error: " + res.Messages[0].Summary); } } catch (Exception ex) { Console.WriteLine("Error in CompanySave: " + ex); } return res.CompanyId; //Return the newly-created companyId }