public ProspectCustomerEditModel SaveProspectCustomer(ProspectCustomerEditModel model) { //since guid is unavailable for this screen , OnlineRequestStatus is set to valid directly. var onlineRequestValidationModel = new OnlineRequestValidationModel() { RequestStatus = OnlineRequestStatus.Valid }; model.RequestValidationModel = onlineRequestValidationModel; if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid) { return(model); } var prospectCustomer = Mapper.Map <ProspectCustomerEditModel, ProspectCustomer>(model); prospectCustomer.CreatedOn = DateTime.Now; _prospectCustomerRepository.Save(prospectCustomer); return(model); }
public ProspectCustomerEditModel SaveProspectCustomerAndUpdateCart(string guid, ProspectCustomerEditModel prospectCustomerEditModel) { var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(guid); prospectCustomerEditModel.RequestValidationModel = onlineRequestValidationModel; if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid) { return(prospectCustomerEditModel); } var prospectCustomer = Mapper.Map <ProspectCustomerEditModel, ProspectCustomer>(prospectCustomerEditModel); prospectCustomer.FirstName = prospectCustomer.FirstName.ToUppercaseInitalLetter(); prospectCustomer.LastName = prospectCustomer.LastName.ToUppercaseInitalLetter(); var tempCart = onlineRequestValidationModel.TempCart; if (prospectCustomerEditModel.Address != null) { prospectCustomer.Address.StreetAddressLine1 = prospectCustomer.Address.StreetAddressLine1.ToUppercaseInitalLetter(false); prospectCustomer.Address.StreetAddressLine2 = prospectCustomer.Address.StreetAddressLine2.ToUppercaseInitalLetter(false); if (prospectCustomerEditModel.Address.StateId > 0) { var state = _stateRepository.GetState(prospectCustomerEditModel.Address.StateId); prospectCustomer.Address.State = state.Name; } prospectCustomer.Address.ZipCode = new ZipCode(tempCart.ZipCode); } else { prospectCustomer.Address = new Address { ZipCode = new ZipCode(tempCart.ZipCode) }; } var inDb = ((IProspectCustomerRepository)_prospectCustomerRepository).GetProspectCustomermatchingConditions( prospectCustomer.FirstName, prospectCustomer.LastName, prospectCustomer.Email != null ? prospectCustomer.Email.ToString() : "", prospectCustomer.CallBackPhoneNumber != null ? prospectCustomer.CallBackPhoneNumber.ToString() : ""); if (tempCart.CustomerId > 0) { return(prospectCustomerEditModel); } if (tempCart.ProspectCustomerId != null && tempCart.ProspectCustomerId > 0) { var prospectCustomerinDb = _prospectCustomerRepository.GetById(tempCart.ProspectCustomerId.Value); prospectCustomer.CreatedOn = prospectCustomerinDb.CreatedOn; prospectCustomer.Id = prospectCustomerinDb.Id; } else if (inDb != null) { inDb.Email = prospectCustomer.Email ?? inDb.Email; inDb.CustomerId = null; inDb.IsConverted = false; inDb.Status = (long)ProspectCustomerConversionStatus.NotConverted; inDb.CallBackPhoneNumber = prospectCustomer.CallBackPhoneNumber ?? inDb.CallBackPhoneNumber; inDb.BirthDate = prospectCustomer.BirthDate ?? inDb.BirthDate; inDb.Address = prospectCustomer.Address != null && !prospectCustomer.Address.IsEmpty() ? prospectCustomer.Address : inDb.Address; inDb.MarketingSource = prospectCustomer.MarketingSource; inDb.Gender = prospectCustomer.Gender; prospectCustomer = inDb; } else { prospectCustomer.CreatedOn = DateTime.Now; prospectCustomer.IsConverted = false; prospectCustomer.Status = (long)ProspectCustomerConversionStatus.NotConverted; } prospectCustomer = _prospectCustomerRepository.Save(prospectCustomer); if (prospectCustomer.Id > 0) { if (!string.IsNullOrEmpty(prospectCustomer.MarketingSource)) { tempCart.MarketingSource = prospectCustomer.MarketingSource; } tempCart.ProspectCustomerId = prospectCustomer.Id; tempCart.Dob = prospectCustomer.BirthDate ?? tempCart.Dob; _tempcartService.SaveTempCart(tempCart); } return(prospectCustomerEditModel); }