public ActionResult Create(OnSiteRegistrationEditModel model) { if (ModelState.IsValid) { try { using (var scope = new TransactionScope()) { var order = _customerRegistrationService.RegisterOnsiteCustomer(model); scope.Complete(); if (order.DiscountedTotal > 0) { Response.RedirectUser("/Scheduling/EventCustomerList/Index?id=" + model.EventId + "&customerIdforAcceptPayment=" + order.CustomerId); return(null); } Response.RedirectUser("/Scheduling/EventCustomerList/Index?id=" + model.EventId); return(null); } } catch (Exception ex) { model = _eventPackageSelectorService.SetEventAndPackageDetail(model, model.EventId, Roles.Technician); model.FeedbackMessage = FeedbackMessageModel.CreateFailureMessage("System Error:" + ex.Message); return(View(model)); } } model = _eventPackageSelectorService.SetEventAndPackageDetail(model, model.EventId, Roles.Technician); return(View(model)); }
public Order RegisterCustomerOnSite(OnSiteRegistrationEditModel model) { using (var scope = new TransactionScope()) { var order = _customerRegistrationService.RegisterOnsiteCustomer(model); scope.Complete(); return(order); } }
public Customer CreateCustomer(OnSiteRegistrationEditModel model, OrganizationRoleUser createdByOrgRoleUser) { var customer = new Customer { Name = new Name { FirstName = model.FirstName, LastName = model.LastName }, HomePhoneNumber = model.HomeNumber }; if (!string.IsNullOrEmpty(model.Email)) { string[] emailSplitUp = model.Email.Split(new[] { '@' }); customer.Email = new Email { Address = emailSplitUp[0], DomainName = emailSplitUp[1] }; } customer.Address = Mapper.Map <AddressEditModel, Address>(model.Address); customer.UserLogin = new UserLogin { UserName = GenerateUniqueUserName(model.FirstName + "." + model.LastName), Password = GenerateUniquePassword(), IsSecurityQuestionVerified = false, UserVerified = false }; customer.Gender = (Gender)model.Gender; if (model.DateofBirth.HasValue) { customer.DateOfBirth = model.DateofBirth; } customer.AddedByRoleId = createdByOrgRoleUser.RoleId; customer.EmployeeId = model.EmployeeId; customer.InsuranceId = model.InsuranceId; var height = new Height(model.HeightInFeet, model.HeightInInch); customer.Height = height.TotalInches > 0 ? height : null; if (model.Weight > 0) { customer.Weight = new Weight(model.Weight); } customer.Race = (Race)System.Enum.Parse(typeof(Race), model.Race, true); return(customer); }
public OnSiteRegistrationEditModel SetEventAndPackageDetail(OnSiteRegistrationEditModel model, long eventId, Roles role) { if (model == null) { model = new OnSiteRegistrationEditModel(); } var theEvent = _eventRepository.GetById(eventId); model.EventId = theEvent.Id; model.EventDate = theEvent.EventDate; model.EventName = theEvent.Name; var eventPackages = _eventPackageRepository.GetPackagesForEventByRole(eventId, (long)role); var parentRole = (Roles)GetParentRoleIdByRoleId((long)role); var enableAlaCarte = Convert.ToBoolean(_configurationRepository.GetConfigurationValue(ConfigurationSettingName.EnableAlaCarte)); if (enableAlaCarte) { if (role == Roles.Customer || parentRole == Roles.Customer) { enableAlaCarte = theEvent.EnableAlaCarteOnline; } else if (role == Roles.CallCenterRep || role == Roles.CallCenterManager || parentRole == Roles.CallCenterRep || parentRole == Roles.CallCenterManager) { enableAlaCarte = theEvent.EnableAlaCarteCallCenter; } else if (role == Roles.Technician || parentRole == Roles.Technician) { enableAlaCarte = theEvent.EnableAlaCarteTechnician; } else if (!(theEvent.EnableAlaCarteOnline || theEvent.EnableAlaCarteCallCenter || theEvent.EnableAlaCarteTechnician)) { enableAlaCarte = false; } } var eventTests = enableAlaCarte ? _eventTestRepository.GetTestsForEventByRole(eventId, (long)role) : null; eventPackages = eventPackages != null?eventPackages.OrderByDescending(d => d.Price) : null; eventTests = eventTests != null?eventTests.OrderByDescending(d => d.Price) : null; model.AllEventPackages = Mapper.Map <IEnumerable <EventPackage>, IEnumerable <EventPackageOrderItemViewModel> >(eventPackages); model.AllEventTests = Mapper.Map <IEnumerable <EventTest>, IEnumerable <EventTestOrderItemViewModel> >(eventTests); model.Appointments = _slotService.GetSlots(model.EventId, AppointmentStatus.Free); return(model); }
public OnsiteCustomerRegistrationResponse RegisterCustomer(OnSiteRegistrationEditModel model) { var customerRegistrationResponse = new OnsiteCustomerRegistrationResponse { IsSuccess = false }; try { var result = _onSiteRegistrationModel.Validate(model); if (result.IsValid) { try { var order = _onSiteRegistrationService.RegisterCustomerOnSite(model); customerRegistrationResponse.AppointmentViewModel = _onSiteRegistrationService.FetchEventCustomerDetail(model.EventId, order.CustomerId); customerRegistrationResponse.IsSuccess = true; } catch (Exception ex) { _logger.Error(string.Format("message : {0} \n stack trace {1}", ex.Message, ex.StackTrace)); customerRegistrationResponse.Message = ex.Message; } } else { var firstOrDefault = result.Errors.First(); customerRegistrationResponse.Message = firstOrDefault.ErrorMessage; } } catch (Exception ex) { _logger.Error(string.Format("message : {0} \n stack trace {1}", ex.Message, ex.StackTrace)); } return(customerRegistrationResponse); }
public Order RegisterOnsiteCustomer(OnSiteRegistrationEditModel model) { var createdByOrgRoleUser = Mapper.Map <OrganizationRoleUserModel, OrganizationRoleUser>(_sessionContext.UserSession.CurrentOrganizationRole); var customer = _massRegistrationEditModelFactory.CreateCustomer(model, createdByOrgRoleUser); _customerService.SaveCustomer(customer, createdByOrgRoleUser.Id); var forOrgRoleUser = _orgRoleUserRepository.GetOrganizationRoleUser(customer.CustomerId); var orderables = new List <IOrderable>(); long packageId = 0; IEnumerable <long> testIds = null; if (model.SelectedPackageId > 0) { var eventPackage = _eventPackageRepository.GetById(model.SelectedPackageId); packageId = eventPackage.PackageId; orderables.Add(eventPackage); } if (model.SelectedTestIds != null && model.SelectedTestIds.Count() > 0) { var eventTests = _eventTestRepository.GetbyIds(model.SelectedTestIds); testIds = eventTests.Select(et => et.TestId).ToArray(); if (model.SelectedPackageId > 0) { foreach (var eventTest in eventTests) { eventTest.Price = eventTest.WithPackagePrice; } } orderables.AddRange(eventTests); } var screeningTime = _eventPackageSelectorService.GetScreeningTime(model.SelectedPackageId, model.SelectedTestIds); var slots = _eventSchedulingSlotService.BookSlotTemporarily(model.SelectedAppointmentId, screeningTime, packageId, testIds); if (slots.IsNullOrEmpty()) { throw new InvalidOperationException("Slot is booked by some other customer."); } var eventCustomer = SaveEventCustomer(createdByOrgRoleUser, model.SelectedAppointmentId, model.EventId, customer.CustomerId); //var shippingAddress = Mapper.Map<AddressEditModel, Address>(model.Address); //var shippingDetail = SaveShippingDetail(shippingAddress, createdByOrgRoleUser); var order = PlaceOrder(forOrgRoleUser, createdByOrgRoleUser, orderables, eventCustomer, null, null); var eventData = _eventRepository.GetById(model.EventId); SendNotification(customer, eventData, createdByOrgRoleUser, "/Scheduling/OnSiteRegistration/Create"); order.CustomerId = customer.CustomerId; try { _eventSchedulingSlotService.SendEventFillingNotification(model.EventId, createdByOrgRoleUser.Id); } catch (Exception) { } return(order); }