Пример #1
0
        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);
        }
Пример #2
0
        /// <summary>
        /// Create an individual event fee
        /// </summary>
        /// <param name="eventId">Event id</param>
        /// <param name="eventFee">EventFee object</param>
        /// <returns>The newly created EventFee</returns>
        public EventFee PostEventFee(string eventId, EventFee eventFee)
        {
            if (string.IsNullOrWhiteSpace(eventId))
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.InvalidId);
            }
            if (eventFee == null)
            {
                throw new IllegalArgumentException(CTCT.Resources.Errors.ObjectNull);
            }

            string url = String.Format(String.Concat(Settings.Endpoints.Default.BaseUrl, Settings.Endpoints.Default.EventFees), eventId, null);

            string json = eventFee.ToJSON();

            RawApiResponse response = RestClient.Post(url, UserServiceContext.AccessToken, UserServiceContext.ApiKey, json);

            try
            {
                var evFee = response.Get <EventFee>();
                return(evFee);
            }
            catch (Exception ex)
            {
                throw new CtctException(ex.Message, ex);
            }
        }
Пример #3
0
            public async Task <bool> Handle(AddAdditionalEventChargeCommand request, CancellationToken cancellationToken)
            {
                EventFee _additionalEventFee = new EventFee
                {
                    EventID          = request.MyAdditionalEventFeeVM.EventID,
                    Description      = request.MyAdditionalEventFeeVM.Description,
                    Item             = request.MyAdditionalEventFeeVM.Item,
                    Quantity         = request.MyAdditionalEventFeeVM.Quantity,
                    PricePerQuantity = request.MyAdditionalEventFeeVM.PricePerQuantity,
                    TotalPrice       = request.MyAdditionalEventFeeVM.PricePerQuantity * request.MyAdditionalEventFeeVM.Quantity
                };

                dbContext.EventFees.Add(_additionalEventFee);
                await dbContext.SaveChangesAsync();

                return(true);
            }
Пример #4
0
        public ServiceResult CreateEventFee(EventFee fee)
        {
            var result = new ServiceResult();

            try
            {
                if (ValidateEventFee(fee, result))
                {
                    _repository.EventFees.Create(fee);

                    if (!_sharedRepository)
                    {
                        _repository.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }

            return(result);
        }
Пример #5
0
        public ServiceResult RemoveEventFee(int purchaseItemId)
        {
            var result = new ServiceResult();

            try
            {
                EventFee feeToDelete = _repository.EventFees.Find(x => x.PurchaseItemId == purchaseItemId);

                if (CanRemoveEventFee(feeToDelete, result))
                {
                    _repository.EventFees.Delete(feeToDelete);
                    if (!_sharedRepository)
                    {
                        _repository.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }

            return(result);
        }
Пример #6
0
        public bool SendPaymentConfirmationEmail(int CartId)
        {
            var needToSendConfirmation = false;

            try
            {
                Cart cart = _repository.Carts.Find(x => x.CartId == CartId);

                StringBuilder cartBody = new StringBuilder();

                String city = string.Empty;
                String date = string.Empty;

                foreach (var item in cart.CartItems)
                {
                    cartBody.Append("<tr>");

                    Registration reg;
                    string       purchaseName        = string.Empty;
                    string       purchaseDescription = string.Empty;
                    string       purchaseCost        = item.Total.ToString();

                    if (item.PurchaseItem is EventFee)
                    {
                        EventFee fee = (EventFee)item.PurchaseItem;
                        purchaseName = fee.EventFeeType.GetAttributeValue <DisplayAttribute>(x => x.Name);

                        switch (fee.EventFeeType)
                        {
                        case EventFeeType.Transfer:
                            purchaseDescription = "fee associated with transfering your event to a friend.";

                            // since an email is sent on transfer, no need to send one here - JJO 4/22/2014
                            continue;
                            break;

                        case EventFeeType.Cancellation:
                            purchaseDescription = "fee associated with cancelling your registration.";


                            // since an email is sent on transfer, no need to send one here - JJO 4/22/2014
                            continue;
                            break;

                        default:
                            needToSendConfirmation = true;
                            reg = _repository.Registrations.Find(x => x.CartItemId == item.CartItemId);
                            if (reg != null)
                            {
                                purchaseDescription = string.Format("{0}, {1} : {2} {3}", reg.EventWave.EventDate.Event.GeneralLocality, reg.EventWave.EventDate.Event.Region.Code, reg.EventWave.EventDate.DateOfEvent.ToString("dddd  MMMM, dd yyyy"), reg.EventWave.StartTime.ToString("h:mm tt"));
                                city = reg.EventWave.EventDate.Event.GeneralLocality;
                                date = reg.EventWave.EventDate.DateOfEvent.Date.ToShortDateString();
                            }
                            break;
                        }
                    }

                    if (item.PurchaseItem is CartCharge)
                    {
                        CartCharge charge = (CartCharge)item.PurchaseItem;
                        purchaseName        = charge.Name;
                        purchaseDescription = charge.Description;
                    }

                    cartBody.Append(string.Format("<td style='padding:0 0 20px;'><table cellpadding='0' cellspacing='0' border='0' bgcolor='#ffffff'><tr><td valign='top' width='150' align='left'><p style='font-family: Arial; font-size: 11px; color:#573f3f;padding:0 10px 0 0;'>{0}</p></td><td valign='top' width='350' align='left'><p style='font-family: Arial; font-size: 11px; color:#573f3f;padding:0 40px 0 0;'>{1}</p></td><td valign='top' width='30' align='left'><p style='font-family: Arial; font-size: 11px; color:#573f3f;'>{2}</p></td></tr></table></td>", purchaseName, purchaseDescription, purchaseCost));

                    cartBody.Append("</tr>");
                }

                if (needToSendConfirmation)     // do we still need to send anything?
                {
                    cartBody.Append(
                        string.Format(
                            "<tr><td><p style='font-family: Arial; font-size: 11px; color:#573f3f;'>Total: {0}</p></td></tr>",
                            cart.TotalCost));

                    string messageBody = File.ReadAllText(emailTemplatePath +
                                                          DirtyGirlServiceConfig.Settings.PaymentConfirmationEmailBody)
                                         .Replace("{FirstName}", cart.User.FirstName)
                                         .Replace("{LastName}", cart.User.LastName)
                                         .Replace("{PaymentId}", cart.TransactionId)
                                         .Replace("{City}", city)
                                         .Replace("{Date}", date)
                                         .Replace("{Cart}", cartBody.ToString());

                    SendEmail(cart.User.EmailAddress,
                              string.Format(DirtyGirlServiceConfig.Settings.PaymentConfirmationEmailSubject, city),
                              messageBody);
                }
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(false);
            }

            return(true);
        }
Пример #7
0
 private bool ValidateEventFee(EventFee feeToValidate, ServiceResult result)
 {
     return(result.Success);
 }
Пример #8
0
        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);
        }
Пример #9
0
        /// <summary>
        /// Create an individual event fee
        /// </summary>
        /// <param name="accessToken">Constant Contact OAuth2 access token</param>
        /// <param name="apiKey">The API key for the application</param>
        /// <param name="eventId">Event id</param>
        /// <param name="eventFee">EventFee object</param>
        /// <returns>The newly created EventFee</returns>
        public EventFee PostEventFee(string accessToken, string apiKey, string eventId, EventFee eventFee)
        {
            string url = String.Format(String.Concat(Config.Endpoints.BaseUrl, Config.Endpoints.EventFees), eventId, null);

            string json = eventFee.ToJSON();

            CUrlResponse response = RestClient.Post(url, accessToken, apiKey, json);

            if (response.HasData)
            {
                return(response.Get <EventFee>());
            }
            else if (response.IsError)
            {
                throw new CtctException(response.GetErrorMessage());
            }
            return(new EventFee());
        }
Пример #10
0
        public ActionResult Ajax_DeleteEventFee([DataSourceRequest] DataSourceRequest request, EventFee fee)
        {
            ServiceResult result = _eventService.RemoveEventFee(fee.PurchaseItemId);

            if (!result.Success)
            {
                Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors());
            }

            return(Json(ModelState.ToDataSourceResult()));
        }
Пример #11
0
        public ActionResult Ajax_UpdateEventFee([DataSourceRequest] DataSourceRequest request, EventFee fee)
        {
            if (ModelState.IsValid)
            {
                ServiceResult result = _eventService.UpdateEventFee(fee);

                if (!result.Success)
                {
                    Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors());
                }
            }

            return(Json(ModelState.ToDataSourceResult()));
        }
Пример #12
0
        public ActionResult Ajax_CreateEventFee([DataSourceRequest] DataSourceRequest request, EventFee fee, int masterEventId)
        {
            if (ModelState.IsValid)
            {
                fee.EventId      = masterEventId;
                fee.Discountable = true;
                ServiceResult result = _eventService.CreateEventFee(fee);

                if (!result.Success)
                {
                    Utilities.AddModelStateErrors(this.ModelState, result.GetServiceErrors());
                }
            }

            return(Json(new[] { fee }.ToDataSourceResult(request, ModelState)));
        }