public DsrAliasModel CreateDsrAlias(Guid userId, string email, Dsr dsr) { DsrAlias alias = new DsrAlias(); alias.UserId = userId; alias.UserName = email; alias.BranchId = dsr.Branch; alias.DsrNumber = dsr.DsrNumber; _repo.Create(alias); _uow.SaveChanges(); return(alias.ToModel()); }
public Dsr GetDsr(string branchId, string dsrNumber) { Dsr returnValue = new Dsr(); var d = _dsrRepository.GetDsrByBranchAndDsrNumber(branchId, dsrNumber); if (d != null) { returnValue = ToDsrModel(d); } else { returnValue = GetDefault(branchId); } return(returnValue); }
private List <Customer> BuildCustomerList(List <CommerceEntity> organizations) { var customers = new System.Collections.Concurrent.BlockingCollection <Customer>(); Dictionary <string, Dsr> dsrDict = RetrieveDsrDictionary(); Dictionary <string, string> termDict = RetrieveTermsCodeDict(); System.Threading.Tasks.Parallel.ForEach(organizations, e => { Organization org = new KeithLink.Svc.Core.Models.Generated.Organization(e); if (org.OrganizationType == ORGANIZATION_TYPE_CUSTOMER) { Customer myCustomer = org.ToCustomer(); string termKey = GetTermKey(org.BranchNumber, org.TermCode); if (termDict.ContainsKey(termKey)) { myCustomer.TermDescription = termDict[termKey]; } string dsrKey = GetDsrKey(myCustomer.CustomerBranch, myCustomer.DsrNumber); Dsr myDsr = null; if (dsrDict.ContainsKey(dsrKey)) { myDsr = dsrDict[dsrKey]; } else { dsrKey = GetDsrKey(myCustomer.CustomerBranch, DEFAULT_DSR_NUMBER); if (dsrDict.ContainsKey(dsrKey)) { myDsr = dsrDict[dsrKey]; } } myCustomer.Dsr = myDsr; customers.Add(myCustomer); } }); return(customers.ToList()); }
public void CreateOrUpdateDsr(Dsr dsr) { var existingDsr = _dsrRepository.Read(d => d.BranchId.Equals(dsr.Branch, StringComparison.CurrentCultureIgnoreCase) && d.DsrNumber.Equals(dsr.DsrNumber)).FirstOrDefault(); if (existingDsr == null) { _dsrRepository.Create(DsrExtensions.ToEFDsr(dsr)); } else { existingDsr.EmailAddress = dsr.EmailAddress; existingDsr.ImageUrl = dsr.ImageUrl; existingDsr.Name = dsr.Name; existingDsr.Phone = dsr.PhoneNumber; _dsrRepository.Update(existingDsr); } unitOfWork.SaveChanges(); }