Exemple #1
0
        public async Task <EventScheduleViewModel> SaveEventDetail([FromBody] EventScheduleViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var session = await _sessionProvider.Get();

                    model.EventScheduleModel.StartDateTime = new DateTime(model.EventScheduleModel.StartDateTime.Year, model.EventScheduleModel.StartDateTime.Month, model.EventScheduleModel.StartDateTime.Day, Convert.ToInt32(model.EventScheduleModel.LocalStartTime.Split(":")[0]), Convert.ToInt32(model.EventScheduleModel.LocalStartTime.Split(":")[1]), 0);
                    model.EventScheduleModel.EndDateTime   = new DateTime(model.EventScheduleModel.EndDateTime.Year, model.EventScheduleModel.EndDateTime.Month, model.EventScheduleModel.EndDateTime.Day, Convert.ToInt32(model.EventScheduleModel.LocalEndTime.Split(":")[0]), Convert.ToInt32(model.EventScheduleModel.LocalEndTime.Split(":")[1]), 0);
                    if (!model.EventScheduleModel.TimeZoneOffset.Contains("-") && !model.EventScheduleModel.TimeZoneOffset.Contains("+"))
                    {
                        model.EventScheduleModel.TimeZoneOffset = "+" + model.EventScheduleModel.TimeZoneOffset;
                    }
                    model.EventScheduleModel.StartDateTime = _utcTimeProvider.GetUtcTime(model.EventScheduleModel.StartDateTime, model.EventScheduleModel.TimeZoneOffset);
                    model.EventScheduleModel.EndDateTime   = _utcTimeProvider.GetUtcTime(model.EventScheduleModel.EndDateTime, model.EventScheduleModel.TimeZoneOffset);
                    model.EventScheduleModel.VenueId       = 10694;
                    EventScheduleCommandResult eventDetailsCommandResult = await _commandSender.Send <EventScheduleCommand, EventScheduleCommandResult>(new EventScheduleCommand
                    {
                        CurrentStep        = model.CurrentStep,
                        EventScheduleModel = model.EventScheduleModel,
                        ModifiedBy         = session.User != null ? session.User.AltId : Guid.Parse("7390283B-4A32-4860-BA3D-B57F1E5F2DAC"),
                    });

                    if (eventDetailsCommandResult.Success)
                    {
                        eventDetailsCommandResult.EventScheduleModel.LocalStartDateTime = _localTimeProvider.GetLocalTime(eventDetailsCommandResult.EventScheduleModel.StartDateTime, eventDetailsCommandResult.EventScheduleModel.TimeZoneOffset);
                        eventDetailsCommandResult.EventScheduleModel.LocalEndDateTime   = _localTimeProvider.GetLocalTime(eventDetailsCommandResult.EventScheduleModel.EndDateTime, eventDetailsCommandResult.EventScheduleModel.TimeZoneOffset);
                        return(new EventScheduleViewModel
                        {
                            Success = true,
                            CurrentStep = eventDetailsCommandResult.CurrentStep,
                            CompletedStep = eventDetailsCommandResult.CompletedStep,
                            EventScheduleModel = eventDetailsCommandResult.EventScheduleModel
                        });
                    }
                    else
                    {
                        return(new EventScheduleViewModel {
                        });
                    }
                }
                catch (Exception e)
                {
                    return(new EventScheduleViewModel {
                    });
                }
            }
            else
            {
                return(new EventScheduleViewModel {
                });
            }
        }
Exemple #2
0
        public async Task <EventScheduleViewModel> SaveSchedule([FromBody] EventRecurranceViewModel eventRecurranceViewModel)
        {
            try
            {
                var session = await _sessionProvider.Get();

                if (eventRecurranceViewModel.EventDetailId == 0)
                {
                    EventScheduleCommandResult eventDetailsCommandResult1 = await _commandSender.Send <EventScheduleCommand, EventScheduleCommandResult>(new EventScheduleCommand
                    {
                        CurrentStep        = eventRecurranceViewModel.CurrentStep,
                        EventFrequencyType = Contracts.Enums.EventFrequencyType.Recurring,
                        EventScheduleModel = new Contracts.Models.CreateEventV1.EventScheduleModel
                        {
                            EventId             = eventRecurranceViewModel.EventId,
                            StartDateTime       = eventRecurranceViewModel.StartDateTime,
                            EndDateTime         = eventRecurranceViewModel.EndDateTime,
                            EventFrequencyType  = Contracts.Enums.EventFrequencyType.Recurring,
                            IsEnabled           = true,
                            LocalStartTime      = "00:00",
                            LocalEndTime        = "00:00",
                            TimeZoneAbbrivation = eventRecurranceViewModel.TimeZoneAbbrivation,
                            TimeZoneOffset      = eventRecurranceViewModel.TimeZoneOffset,
                            VenueId             = 1094
                        },
                        ModifiedBy = session.User != null ? session.User.AltId : Guid.Parse("7390283B-4A32-4860-BA3D-B57F1E5F2DAC"),
                    });

                    if (!eventDetailsCommandResult1.Success)
                    {
                        return(new EventScheduleViewModel {
                        });
                    }
                }
                var eventDetailsCommandResult = await _commandSender.Send <EventRecurranceCommand, EventRecurranceCommandResult>(new EventRecurranceCommand
                {
                    ActionType          = ActionType.BulkInsert,
                    EventScheduleId     = eventRecurranceViewModel.EventScheduleId,
                    ScheduleDetailId    = eventRecurranceViewModel.ScheduleDetailId,
                    StartDateTime       = eventRecurranceViewModel.StartDateTime,
                    EndDateTime         = eventRecurranceViewModel.EndDateTime,
                    DayIds              = eventRecurranceViewModel.DayIds,
                    EventId             = eventRecurranceViewModel.EventId,
                    LocalStartTime      = eventRecurranceViewModel.LocalStartTime,
                    LocalEndTime        = eventRecurranceViewModel.LocalEndTime,
                    OccuranceCount      = eventRecurranceViewModel.OccuranceCount,
                    OccuranceType       = eventRecurranceViewModel.OccuranceType,
                    TimeZoneOffSet      = eventRecurranceViewModel.TimeZoneOffset,
                    EventFrequencyType  = eventRecurranceViewModel.EventFrequencyType,
                    TimeZoneAbbrivation = eventRecurranceViewModel.TimeZoneAbbrivation,
                    ModifiedBy          = session.User != null ? session.User.AltId : Guid.Parse("7390283B-4A32-4860-BA3D-B57F1E5F2DAC")
                });

                if (eventDetailsCommandResult.Success)
                {
                    return(new EventScheduleViewModel
                    {
                        Success = true
                    });
                }
                else
                {
                    return(new EventScheduleViewModel {
                    });
                }
            }
            catch (Exception e)
            {
                return(new EventScheduleViewModel {
                });
            }
        }