protected override Task <ICommandResult> Handle(ZEventCommand command)
        {
            if (!command.IsEditEvent)
            {
                try
                {
                    ZEventCommandResult ZEventDataResult = new ZEventCommandResult();
                    var eventData = new Event
                    {
                        AltId = Guid.NewGuid(),
                        Name  = command.Name,
                        TermsAndConditions     = command.TermsAndConditions == null ? String.Empty : command.TermsAndConditions,
                        ClientPointOfContactId = 1,
                        IsPublishedOnSite      = true,
                        Description            = command.Description,
                        EventCategoryId        = command.EventCategoryId,
                        EventTypeId            = command.EventType,
                        MetaDetails            = command.MetaDetails,
                        ModifiedBy             = command.ModifiedBy,
                        CreatedUtc             = DateTime.UtcNow,
                        EventSourceId          = EventSource.None,
                        IsFeel    = false,
                        IsEnabled = false,
                        Slug      = command.Name.ToLower().Replace(' ', '-'),
                        IsCreatedFromFeelAdmin = false,
                        IsDelete = false
                    };
                    FIL.Contracts.DataModels.Event result = _eventRepository.Save(eventData);
                    ZEventDataResult.Id    = result.Id;
                    ZEventDataResult.AltId = result.AltId;
                    return(Task.FromResult <ICommandResult>(ZEventDataResult));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                try
                {
                    var place = _eventRepository.GetByEventId((long)command.Id);
                    ZEventCommandResult ZEventDataResult = new ZEventCommandResult();
                    place.Name = command.Name;
                    place.TermsAndConditions = command.TermsAndConditions;
                    place.Description        = command.Description;
                    place.EventCategoryId    = command.EventCategoryId;
                    place.EventTypeId        = command.EventType;
                    place.MetaDetails        = command.MetaDetails;
                    place.ModifiedBy         = command.ModifiedBy;
                    place.Slug = command.Name.ToLower().Replace(' ', '-');

                    FIL.Contracts.DataModels.Event result = _eventRepository.Save(place);
                    ZEventDataResult.Id    = result.Id;
                    ZEventDataResult.AltId = result.AltId;
                    return(Task.FromResult <ICommandResult>(ZEventDataResult));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Beispiel #2
0
        protected override Task <ICommandResult> Handle(SaveEventCommand command)
        {
            var place = _eventRepository.GetByFeelEventName(command.Name);
            SaveEventDataResult saveEventDataResult = new SaveEventDataResult();
            var eventData = new Event();

            if (place != null && !command.IsEdit)
            {
                command.Id = place.Id;
            }
            int eventCategory = command.EventCategoryId;
            var createdByGuid = command.ModifiedBy;

            if (command.IsEdit)
            {
                var currentEvent = _eventRepository.Get(command.Id);
                command.AltId = currentEvent.AltId;
                eventCategory = currentEvent.EventCategoryId;
                createdByGuid = currentEvent.CreatedBy;
            }
            eventData.AltId = command.AltId;
            eventData.Id    = command.Id;
            eventData.Name  = command.Name;
            eventData.TermsAndConditions     = command.TermsAndConditions;
            eventData.ClientPointOfContactId = command.ClientPointOfContactId;
            eventData.Description            = command.Description;
            eventData.EventCategoryId        = (command.IsEdit ? eventCategory : command.EventCategoryId);
            eventData.EventTypeId            = EventType.Perennial;
            eventData.MetaDetails            = command.MetaDetails;
            eventData.CreatedBy              = (command.IsEdit ? createdByGuid : command.ModifiedBy);
            eventData.ModifiedBy             = command.ModifiedBy;
            eventData.CreatedUtc             = (place != null ? place.CreatedUtc : DateTime.Now);
            eventData.EventSourceId          = EventSource.None;
            eventData.IsFeel                 = command.IsFeel;                           //--
            eventData.IsEnabled              = false;
            eventData.Slug                   = command.Name.ToLower().Replace(' ', '-'); //--
            eventData.IsCreatedFromFeelAdmin = true;
            eventData.IsDelete               = false;

            try
            {
                FIL.Contracts.DataModels.Event result = _eventRepository.Save(eventData);

                if (result != null && result.Id > 0)
                {
                    //savecategorymapping
                    SaveEventCategoryMapping(command, result.Id);
                    //Amenity
                    SaveEventAmentity(command, result.Id);
                    //Save siteid mapping
                    SaveEventSiteId(command, result.Id);
                    //Save Time Duration of place
                    SavePlaceVisitDuration(command, result.Id);
                    //Save Event Tag Mappings
                    SaveEventTagMappings(command, result.Id);
                }
                saveEventDataResult.Id    = result.Id;
                saveEventDataResult.AltId = result.AltId;
            }
            catch (Exception ex)
            {
            }
            return(Task.FromResult <ICommandResult>(saveEventDataResult));
        }