public ServiceResult CreateTeam(Team team, int registrationId) { ServiceResult result = new ServiceResult(); try { team.Name = team.Name.Trim(); team.DateAdded = DateTime.Now; if (ValidateTeam(team, result)) { team.Code = GenerateTeamCode(team.EventId); _repository.Teams.Create(team); var reg = _repository.Registrations.Find(x => x.RegistrationId == registrationId); reg.Team = team; _repository.Registrations.Update(reg); if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(ex.Message); } return result; }
public ServiceResult UpdateEventLead(EventLead eventLead) { var result = new ServiceResult(); try { if (ValidateEventLead(eventLead, result)) { var updateEventLead = _repository.EventLeads.Find(x => x.EventLeadId == eventLead.EventLeadId); updateEventLead.EventLeadTypeId = eventLead.EventLeadTypeId; updateEventLead.DisplayText = eventLead.DisplayText; updateEventLead.Title = eventLead.Title; if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CancelRegistration(int existingRegistrationId) { var result = new ServiceResult(); IEmailService emailService = new EmailService(); IDiscountService discountService = new DiscountService(this._repository, false); Registration cancelReg = _repository.Registrations.Find(x => x.RegistrationId == existingRegistrationId); cancelReg.RegistrationStatus = RegistrationStatus.Cancelled; cancelReg.DateUpdated = DateTime.Now; var newTransferCode = new RedemptionCode { GeneratingRegistrationId = existingRegistrationId, Code = discountService.GenerateDiscountCode(), RedemptionCodeType = RedemptionCodeType.StraightValue, Value = GetRegistrationPathValue(existingRegistrationId), DiscountType = DiscountType.Dollars }; result = discountService.CreateRedemptionCode(newTransferCode); if (!_sharedRepository) { _repository.SaveChanges(); emailService.SendCancellationEmail(newTransferCode.DiscountItemId); } return result; }
public ServiceResult ChangeTeamName(int teamId, string newTeamName) { ServiceResult result = new ServiceResult(); try { var team = this.GetTeamById(teamId); team.Name = newTeamName; _repository.Teams.Update(team); _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(ex.Message); } return result; }
public ServiceResult RemoveEventLead(int eventLeadId) { var result = new ServiceResult(); try { var eventLeadToDelete = _repository.EventLeads.Find(x => x.EventLeadId == eventLeadId); _repository.EventLeads.Delete(eventLeadToDelete); if (!_sharedRepository) _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateRedemptionCode(RedemptionCode redemptionCode) { var result = new ServiceResult(); try { _repository.RedemptionCodes.Create(redemptionCode); if (!_sharedRepository) _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateEventLead(EventLead eventLead) { var result = new ServiceResult(); try { if (ValidateEventLead(eventLead, result)) { _repository.EventLeads.Create(eventLead); if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateCoupon(Coupon coupon) { var result = new ServiceResult(); try { if (ValidateCoupon(coupon, result)) { _repository.Coupons.Create(coupon); if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateUser(User u) { var result = new ServiceResult(); try { if (ValidateUser(u, result)) { //Non-Facebook Users if (u.FacebookId == null) { var chc = Crypto.CreateHash(u.Password); u.Password = chc.hash; u.Salt = chc.salt; u.EmailVerificationCode = DirtyGirlServiceConfig.Settings.UsersMustConfirmEmail ? GenerationEmailConfirmationCode() : null; } //If a user is created with both image data and "User Facebook Image" selected, the uploaded image will be used instead. if (u.Image != null) { u.UseFacebookImage = false; } u.IsActive = true; u.UserName = u.UserName.Trim(); _repository.Users.Create(u); u.Roles = new List<Role>(); u.Roles.Add(_repository.Roles.Find(x => x.Name == "Registrant")); if (result.Success) { _repository.SaveChanges(); SendEmailConfirmation(u.UserId); } } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult GenerateTempTeam(Team newTeam) { var result = new ServiceResult(); try { ITeamService teamService = new TeamService(_repository); if (!teamService.CheckTeamNameForDirtyWords(newTeam.Name)) { result.AddServiceError("TeamName", "Team name contains a naughty word."); } else { if (teamService.CheckTeamNameAvailability(newTeam.EventId, newTeam.Name)) newTeam.Code = teamService.GenerateTeamCode(newTeam.EventId); else result.AddServiceError("TeamName", "Team name is already taken for this event."); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult RemoveEventSponsor(int eventId, string fileName) { var result = new ServiceResult(); try { IQueryable<EventSponsor> sponsorsToDelete = _repository.EventSponsors.Filter(x => x.FileName == fileName && x.EventId == eventId); foreach (EventSponsor sponsorToDelete in sponsorsToDelete) { if (CanRemoveSponsor(sponsorToDelete, result)) { _repository.EventSponsors.Delete(sponsorToDelete); } } _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateNewRegistration(Registration r) { var result = new ServiceResult(); try { if (ValidateRegistration(r, result)) { _repository.Registrations.Create(r); if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateNewRegistration(Registration r, int? redemtpionId) { var result = new ServiceResult(); try { result = CreateNewRegistration(r); if (result.Success) { //Check to see if the discount id being passed in is a redemption code, if it is, update it. var code = _repository.RedemptionCodes.Find(x => x.DiscountItemId == redemtpionId); if (code != null) { code.GeneratingRegistration.RegistrationStatus = code.RedemptionCodeType == RedemptionCodeType.Transfer ? RegistrationStatus.Transferred : RegistrationStatus.Cancelled; code.ResultingRegistrationId = r.RegistrationId; r.ParentRegistrationId = code.GeneratingRegistrationId; if (!_sharedRepository) _repository.SaveChanges(); } } } catch(Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult UpdateEventWave(EventWave ew) { var result = new ServiceResult(); try { if (ValidateEventWave(ew, result)) { EventWave updateWave = _repository.EventWaves.Find(x => x.EventWaveId == ew.EventWaveId); updateWave.StartTime = ew.StartTime; updateWave.EndTime = ew.EndTime; updateWave.IsActive = ew.IsActive; updateWave.MaxRegistrants = ew.MaxRegistrants; _repository.EventWaves.Update(updateWave); if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult ChangeWave(int registrationId, int eventWaveId) { var result = new ServiceResult(); try { Registration existingReg = _repository.Registrations.Find(x => x.RegistrationId == registrationId); int eventId = existingReg.EventWave.EventDate.EventId; int newEventId = GetEventWaveById(eventWaveId).EventDate.EventId; if (existingReg.TeamId != null && eventId != newEventId) existingReg.TeamId = null; existingReg.EventWaveId = eventWaveId; existingReg.DateUpdated = DateTime.Now; if (!_sharedRepository) _repository.SaveChanges(); } catch(Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult UpdateEventFee(EventFee fee) { var result = new ServiceResult(); try { if (ValidateEventFee(fee, result)) { EventFee updateFee = _repository.EventFees.Find(x => x.PurchaseItemId == fee.PurchaseItemId); updateFee.EffectiveDate = fee.EffectiveDate; updateFee.Cost = fee.Cost; if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult UpdateEventSponsor(EventSponsor sponsor) { var result = new ServiceResult(); try { if (ValidateSponsor(sponsor, result)) { EventSponsor updateSponsor = _repository.EventSponsors.Find(x => x.EventSponsorId == sponsor.EventSponsorId); updateSponsor.SponsorName = sponsor.SponsorName; updateSponsor.Description = sponsor.Description; _repository.EventSponsors.Update(updateSponsor); _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult ChangeEvent(int registrationId, int eventWaveId, int? cartItemId, string confirmationCode) { var result = new ServiceResult(); try { Registration existingReg = _repository.Registrations.Find(x => x.RegistrationId == registrationId); existingReg.RegistrationStatus = RegistrationStatus.Changed; existingReg.DateUpdated = DateTime.Now; var newReg = new Registration { EventWaveId = eventWaveId, RegistrationStatus = RegistrationStatus.Active, RegistrationType = existingReg.RegistrationType, ParentRegistrationId = existingReg.RegistrationId, FirstName = existingReg.FirstName, LastName = existingReg.LastName, Address1 = existingReg.Address1, Address2 = existingReg.Address2, Locality = existingReg.Locality, RegionId = existingReg.RegionId, PostalCode = existingReg.PostalCode, PacketDeliveryOption = existingReg.PacketDeliveryOption, Email = existingReg.Email, Phone = existingReg.Phone, EmergencyContact = existingReg.EmergencyContact, EmergencyPhone = existingReg.EmergencyPhone, SpecialNeeds = existingReg.SpecialNeeds, TShirtSize = existingReg.TShirtSize, Gender = existingReg.Gender, UserId = existingReg.UserId, CartItemId = cartItemId, AgreeToTerms = existingReg.AgreeToTerms, AgreeTrademark = existingReg.AgreeTrademark, IsFemale = existingReg.IsFemale, IsOfAge = existingReg.IsOfAge, EventLeadId = existingReg.EventLeadId, IsSignatureConsent = existingReg.IsSignatureConsent, IsThirdPartyRegistration = existingReg.IsThirdPartyRegistration, Signature = existingReg.Signature, Birthday = existingReg.Birthday, IsIAmTheParticipant = existingReg.IsIAmTheParticipant }; if (string.IsNullOrEmpty(confirmationCode)) newReg.ConfirmationCode = existingReg.ConfirmationCode; else newReg.ConfirmationCode = confirmationCode; _repository.Registrations.Create(newReg); if (!_sharedRepository) _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult GenerateEventDate(int eventId, DateTime eventDate, DateTime startTime, DateTime endTime, int duration, int maxRegistrants) { var result = new ServiceResult(); try { var newDate = new EventDate {EventId = eventId, DateOfEvent = eventDate, IsActive = true}; if (ValidateEventDate(newDate, result)) { _repository.EventDates.Create(newDate); DateTime newWaveStartTime = startTime; while (newWaveStartTime.TimeOfDay < endTime.TimeOfDay) { var newWave = new EventWave { EventDateId = newDate.EventDateId, StartTime = new DateTime(eventDate.Year, eventDate.Month, eventDate.Day, newWaveStartTime.Hour, newWaveStartTime.Minute, newWaveStartTime.Second) }; newWave.EndTime = newWave.StartTime.AddMinutes(duration - 1); newWave.IsActive = true; newWave.MaxRegistrants = maxRegistrants; newWaveStartTime = newWaveStartTime.AddMinutes(duration); _repository.EventWaves.Create(newWave); } if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult UpdateRegistration(Registration r) { var result = new ServiceResult(); try { var target = _repository.Registrations.Find(x => x.RegistrationId == r.RegistrationId); if (ValidateRegistration(r, result)) { target.Address1 = r.Address1; target.Address2 = r.Address2; target.AgreeToTerms = r.AgreeToTerms; target.AgreeTrademark = r.AgreeTrademark; target.Birthday = r.Birthday; target.CartItemId = r.CartItemId; target.Email = r.Email; target.EmergencyContact = r.EmergencyContact; target.EmergencyPhone = r.EmergencyPhone; target.EventLeadId = r.EventLeadId; target.EventWaveId = r.EventWaveId; target.FirstName = r.FirstName; target.Gender = r.Gender; target.IsFemale = r.IsFemale; target.IsOfAge = r.IsOfAge; target.IsThirdPartyRegistration = r.IsThirdPartyRegistration; target.LastName = r.LastName; target.Locality = r.Locality; target.MedicalInformation = r.MedicalInformation; target.ParentRegistrationId = r.ParentRegistrationId; target.Phone = r.Phone; target.PostalCode = r.PostalCode; target.PacketDeliveryOption = r.PacketDeliveryOption; target.ReferenceAnswer = r.ReferenceAnswer; target.RegionId = r.RegionId; target.RegistrationStatus = r.RegistrationStatus; target.RegistrationType = r.RegistrationType; target.SpecialNeeds = r.SpecialNeeds; target.TShirtSize = r.TShirtSize; target.TeamId = r.TeamId; target.UserId = r.UserId; target.DateUpdated = DateTime.Now; target.ConfirmationCode = r.ConfirmationCode; if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult RedemptionCodeRegistration(string code, Registration r) { var result = new ServiceResult(); return result; }
public ServiceResult RemoveEventSponsor(int sponsorId) { var result = new ServiceResult(); try { EventSponsor sponsorToDelete = _repository.EventSponsors.Find(x => x.EventSponsorId == sponsorId); if (CanRemoveSponsor(sponsorToDelete, result)) { _repository.EventSponsors.Delete(sponsorToDelete); _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult RemoveEventDate(int eventDateId) { var result = new ServiceResult(); try { EventDate dateToDelete = _repository.EventDates.Find(x => x.EventDateId == eventDateId); List<int> waveIds = dateToDelete.EventWaves.Select(x => x.EventWaveId).ToList(); foreach (int waveId in waveIds) { EventWave wave = dateToDelete.EventWaves.Single(x => x.EventWaveId == waveId); if (CanRemoveEventWave(wave, result)) _repository.EventWaves.Delete(wave); } if (result.Success && CanRemoveEventDate(dateToDelete, result)) { _repository.EventDates.Delete(dateToDelete); _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult CreateEventByTemplate(CreateNewEvent newEvent) { var result = new ServiceResult(); try { EventTemplate template = GetEventTemplateById(newEvent.SelectedTemplateId); var e = new Event { GeneralLocality = newEvent.GeneralLocality, RegionId = newEvent.RegionId, Place = template.DefaultPlaceName, IsActive = false }; int registrationTimeOffset = DirtyGirlServiceConfig.Settings.RegistrationCutoffHours * -1; e.RegistrationCutoff = newEvent.EventDate.AddHours(registrationTimeOffset); int emailPacketOffset = DirtyGirlServiceConfig.Settings.EmailPacketCutoffDays * -1; e.EmailCutoff = newEvent.EventDate.AddDays(emailPacketOffset); ServiceResult saveEventResult = CreateEvent(e); ServiceResult generateDateResult = GenerateEventDate(e.EventId, newEvent.EventDate, template.StartTime, template.EndTime, template.WaveDuration, template.MaxRegistrantsPerWave); var feeResult = new ServiceResult(); var rfee = new EventFee { EventId = e.EventId, EffectiveDate = DateTime.Now.Date, Cost = template.DefaultRegistrationCost, EventFeeType = EventFeeType.Registration, Discountable = true, Taxable = true }; var tFee = new EventFee { EventId = e.EventId, EffectiveDate = DateTime.Now.Date, Cost = template.DefaultTransferFeeCost, EventFeeType= EventFeeType.Transfer, Discountable = false, Taxable = false }; var chFee = new EventFee { EventId = e.EventId, EffectiveDate = DateTime.Now.Date, Cost = template.DefaultChangeFeeCost, EventFeeType = EventFeeType.ChangeEvent, Discountable = false, Taxable = false }; var cfee = new EventFee { EventId = e.EventId, EffectiveDate = DateTime.Now.Date, Cost = template.DefaultCancellationFeeCost, EventFeeType = EventFeeType.Cancellation, Discountable = false, Taxable = false }; var pfee = new EventFee { EventId = e.EventId, EffectiveDate = DateTime.Now.Date, Cost = template.DefaultProcessingFeeCost, EventFeeType = EventFeeType.ProcessingFee, Discountable = false, Taxable = false }; var sfee = new EventFee { EventId = e.EventId, EffectiveDate = DateTime.Now.Date, Cost = template.DefaultShippingFeeCost, EventFeeType = EventFeeType.Shipping, Discountable = false, Taxable = false }; CreateEventFee(rfee); CreateEventFee(tFee); CreateEventFee(chFee); CreateEventFee(cfee); CreateEventFee(sfee); CreateEventFee(pfee); foreach (EventTemplate_PayScale ps in template.PayScales) { var eventStart = newEvent.EventDate; eventStart = newEvent.EventDate.AddDays(-1*ps.DaysOut); // for registrations, if (ps.EventFeeType == EventFeeType.Registration) { while (eventStart.DayOfWeek != DayOfWeek.Wednesday) eventStart = eventStart.AddDays(1); } var newFee = new EventFee { EventId = e.EventId, EffectiveDate = eventStart.Date, Cost = ps.Cost, EventFeeType = ps.EventFeeType, Taxable = ps.Taxable, Discountable = ps.Discountable }; feeResult = CreateEventFee(newFee); if (!feeResult.Success) break; } if (saveEventResult.Success && generateDateResult.Success && feeResult.Success) { _repository.SaveChanges(); newEvent.EventId = e.EventId; } else result.AddServiceError("An Error Occured Creating this Event"); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult Save() { var result = new ServiceResult(); try { _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ServiceResult RemoveEventWave(int eventWaveId) { var result = new ServiceResult(); try { EventWave waveToDelete = _repository.EventWaves.Find(x => x.EventWaveId == eventWaveId); if (CanRemoveEventWave(waveToDelete, result)) { _repository.EventWaves.Delete(waveToDelete); if (!_sharedRepository) _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
private bool ValidateRegistration(Registration registrationToValidate, ServiceResult result) { return result.Success; }
public ServiceResult UpdateEvent(Event e) { var result = new ServiceResult(); try { if (ValidateEvent(e)) { _repository.Events.Update(e); } if (!_sharedRepository) _repository.SaveChanges(); } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }
public ActionResult PasswordResetRequest(vmPasswordReset passwordReset) { var result = new ServiceResult(); if (passwordReset == null) throw new ArgumentNullException("passwordReset"); if (passwordReset.Password == passwordReset.ConfirmPassword && UserService.IsValidPasswordResetToken(passwordReset.ResetToken)) { var user = UserService.GetUserByPasswordResetToken(passwordReset.ResetToken); result = UserService.UpdatePassword(user.UserId, passwordReset.Password); if (result.Success) return RedirectToAction("Index", "Home"); ModelState.AddModelError("Service Error", "Failed to update Password. Please contact support."); return View(passwordReset); } ModelState.AddModelError("Password Mismatch", "Verify the passwords match"); return View(passwordReset); }
public ServiceResult UpdateEventDate(EventDate ed) { var result = new ServiceResult(); try { if (ValidateEventDate(ed, result)) { EventDate updateDate = _repository.EventDates.Find(x => x.EventDateId == ed.EventDateId); updateDate.DateOfEvent = ed.DateOfEvent; foreach (EventWave w in updateDate.EventWaves) { w.StartTime = new DateTime(ed.DateOfEvent.Year, ed.DateOfEvent.Month, ed.DateOfEvent.Day, w.StartTime.Hour, w.StartTime.Minute, w.StartTime.Second); w.EndTime = new DateTime(ed.DateOfEvent.Year, ed.DateOfEvent.Month, ed.DateOfEvent.Day, w.EndTime.Hour, w.EndTime.Minute, w.EndTime.Second); } _repository.SaveChanges(); } } catch (Exception ex) { result.AddServiceError(Utilities.GetInnerMostException(ex)); } return result; }