public OnlineSelectedEventEditModel SaveSelectedEvent(OnlineSelectedEventEditModel model) { var onlineRequestValidationModel = _tempcartService.ValidateOnlineRequest(model.Guid); model.RequestValidationModel = onlineRequestValidationModel; if (onlineRequestValidationModel.RequestStatus != OnlineRequestStatus.Valid) { return(model); } onlineRequestValidationModel.TempCart = _onlineEventService.SaveSelectedEvent(onlineRequestValidationModel.TempCart, model); return(model); }
public TempCart SaveSelectedEvent(TempCart tempCart, OnlineSelectedEventEditModel model) { long sourceCodeId = 0; if (!string.IsNullOrEmpty(model.CouponCode)) { var sourceCode = _sourceCodeRepository.GetSourceCodeByCode(model.CouponCode); if (sourceCode != null) { sourceCodeId = sourceCode.Id; } } if (tempCart == null) { tempCart = new TempCart { ZipCode = model.ZipCode, EventId = model.EventId, InvitationCode = model.InvitationCode, CorpCode = model.InvitationCode, Radius = model.Radius, Guid = Guid.NewGuid().ToString(), EntryPage = model.RequestUrl, ExitPage = model.RequestUrl, SourceCodeId = sourceCodeId > 0 ? (long?)sourceCodeId : null }; } else { if (tempCart.EventId != model.EventId) { tempCart.ZipCode = string.IsNullOrEmpty(model.ZipCode) ? tempCart.ZipCode : model.ZipCode; tempCart.Radius = model.Radius.HasValue ? model.Radius : tempCart.Radius; tempCart.EventId = model.EventId; tempCart.ExitPage = model.RequestUrl; tempCart.EventPackageId = null; tempCart.TestId = null; tempCart.ShippingId = null; tempCart.ProductId = null; tempCart.PreliminarySelectedTime = null; tempCart.AppointmentId = null; tempCart.InChainAppointmentSlots = null; if (tempCart.AppointmentId.HasValue) { _eventSchedulingSlotRepository.ReleaseSlots(tempCart.InChainAppointmentSlotIds); } } } if (tempCart.Id > 0) { tempCart.DateModified = DateTime.Now; } else { tempCart.DateCreated = DateTime.Now; } tempCart = _tempCartRepository.Save(tempCart); return(tempCart); }