Exemplo n.º 1
0
        public IEnumerable<CompanyMaster> GetAllRegisteredCompanies()
        {
            return ExecuteFaultHandledOperation(() =>
            {
                ICompanyMasterRepository companyMasterRepository
                  = _DataRepositoryFactory.GetDataRepository<ICompanyMasterRepository>();
                List<CompanyMaster> results = companyMasterRepository.Get().ToList();

                CompanyMaster company = new CompanyMaster
                {
                    CompanyKey = ALL,
                    Name = ALL,
                    ContactPerson = ALL
                };
                results.Insert(0, company);
                return results;
            });
        }
Exemplo n.º 2
0
        public CompanyMaster CreateCompanyForSelectedUser(string userId, CompanyMaster company)
        {
            return ExecuteFaultHandledOperation(() =>
            {
                ICompanyMasterRepository companyMasterRepository = _DataRepositoryFactory.GetDataRepository<ICompanyMasterRepository>();
                IUserCompanyMappingRepository userCompanyRepository = _DataRepositoryFactory.GetDataRepository<IUserCompanyMappingRepository>();

                if (!string.IsNullOrWhiteSpace(company.CompanyKey))
                {
                    CompanyMaster updateCompany = companyMasterRepository.Get(company.CompanyKey);
                    updateCompany.Address = company.Address;
                    updateCompany.Name = company.Name;
                    updateCompany.ContactPerson = company.ContactPerson;
                    updateCompany.Email = company.Email;
                    updateCompany.LocationCoordinates = company.LocationCoordinates;
                    companyMasterRepository.Update(updateCompany);
                }

                else
                {
                    company.CompanyKey = Guid.NewGuid().ToString();
                    companyMasterRepository.Add(company);
                    UserCompanyMapping userCompany = new UserCompanyMapping
                    {
                        UserCompanyKey = Guid.NewGuid().ToString(),
                        UserKey = userId,
                        CompanyKey = company.CompanyKey,
                        IsDeleted = false,
                    };
                    userCompanyRepository.Add(userCompany);
                }
                return company;
            });
        }