Exemplo n.º 1
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());
        }
Exemplo n.º 2
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());
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
 private bool ValidateEventFee(EventFee feeToValidate, ServiceResult result)
 {
     return result.Success;
 }