public void SaveOnlineHealthAssessment(OnlineHealthAssessmentQuestionAnswer model, TempCart tempCart) { _healthAssessmentService.Save(new HealthAssessmentEditModel { CustomerId = tempCart.CustomerId.Value, EventId = tempCart.EventId.Value, QuestionEditModels = model.QuestionEditModels }, 0); var customer = _customerRepository.GetCustomer(tempCart.CustomerId.Value); customer.Height = model.Height > 0 ? new Height { TotalInches = model.Height } : null; customer.Weight = model.Weight > 0 ? new Weight(model.Weight) : null; customer.Race = (Race)model.Race; customer.Waist = model.Waist; _customerService.SaveCustomer(customer, customer.CustomerId); if ((!tempCart.IsHafFilled.HasValue || !tempCart.IsHafFilled.Value) && !model.QuestionEditModels.IsNullOrEmpty()) { tempCart.IsHafFilled = true; } _tempcartService.SaveTempCart(tempCart); }
public OnlineHealthAssessmentQuestionModel SaveHealthAssessment([FromBody] OnlineHealthAssessmentQuestionAnswer model) { var hafModel = new OnlineHealthAssessmentQuestionModel { RequestValidationModel = _tempcartService.ValidateOnlineRequest(model.Guid) }; try { if (model == null) { hafModel.RequestValidationModel.RequestStatus = OnlineRequestStatus.InvalidOperation; return(hafModel); } var tempCart = hafModel.RequestValidationModel.TempCart; if ((hafModel.RequestValidationModel.RequestStatus != OnlineRequestStatus.Valid && hafModel.RequestValidationModel.RequestStatus != OnlineRequestStatus.Completed) || tempCart == null || !(tempCart.EventId.HasValue && tempCart.CustomerId.HasValue)) { return(hafModel); } _onlineHealthAssessmentService.SaveOnlineHealthAssessment(model, tempCart); } catch (Exception ex) { _logger.Error(string.Format("While Save Health Assessment exception {0}", ex.StackTrace)); } return(hafModel); }