public bool ChangeCompanyPassword(Company company, string oldPassword, string newPassword) { CompanyAccessData companyAccessData = Context.CompanyAccessDatas. Include(compData => compData.Company). FirstOrDefault(compData => object.ReferenceEquals(compData.Company, company)); if (companyAccessData.Password.Equals(oldPassword)) { companyAccessData.Password = newPassword; return(true); } return(false); }
public bool AddCompany(Company company, CompanyAccessData companyAccessData) { if (Context.CompanyAccessDatas.FirstOrDefault(compData => compData.Login.Equals(companyAccessData.Login)) == null) { Context.Companies.Add(company); Context.CompanyAccessDatas.Add(companyAccessData); return(true); } else { return(false); } }
public Company SignUpCompany(string name, string login, string mobilePhone, string email, string paswword) { Company company = new Company { Name = name, MobileNumber = mobilePhone, Email = email }; CompanyAccessData compData = new CompanyAccessData { Login = login, Password = paswword, Company = company }; if (CompanyRepository.AddCompany(company, compData)) { CompanyRepository.SaveChages(); return(company); } else { return(null); } }