public InsertEventValidatorTests()
 {
     command = new InsertEventCommand(
         Guid.NewGuid().ToString(),
         Guid.NewGuid().ToString(),
         GetDateTime(1),
         GetDateTime(2),
         "Title"
         );
 }
        public async Task <Event> SaveEventAsync(EventWriteModel eventWriteModel)
        {
            var insertEventCommand = new InsertEventCommand(eventWriteModel);

            using (var session = _sessionFactory.CreateCommandSession())
            {
                await session.ExecuteAsync(insertEventCommand);

                session.Commit();
            }

            return(insertEventCommand.Event);
        }
        public ActionResult Create()
        {
            InsertEventCommand command = new InsertEventCommand();

            return(View(command));
        }
Esempio n. 4
0
        public Event SaveEvent()
        {
            string category         = Request.Form.Get("Event.CategoryId.Id");
            string eventVenue       = Request.Form.Get("Event.Venue");
            string eventName        = Request.Form.Get("Event.EventName");
            string eventDate        = Request.Form.Get("Event.EventDate");
            string ticketQuantity   = Request.Form.Get("Event.Quantity");
            string maxClaims        = Request.Form.Get("Event.Claims");
            string eventDescription = Request.Form.Get("Event.EventDescription");
            string eventId          = Request.Form.Get("Event.EventId");


            DateTime enteredDate           = DateTime.Parse(eventDate);
            DateTime datePosted            = DateTime.Now;
            int      enteredTicketQuantity = int.Parse(ticketQuantity);
            int      categoryId            = int.Parse(category);
            int      enteredMaxClaims      = int.Parse(maxClaims);
            int      postStatus            = 1;
            int      totalHandsRaised      = 0;
            int      maxWinners            = Convert.ToInt32(Math.Floor(Convert.ToDecimal((enteredTicketQuantity / enteredMaxClaims))));
            int      remainingWinners      = maxWinners;

            if (eventId != "")
            {
                int updateEventId = int.Parse(eventId);

                Event updateEvent = ConvertToEvent(eventVenue, eventName, enteredDate, enteredTicketQuantity, enteredMaxClaims,
                                                   categoryId, datePosted, postStatus, eventDescription, totalHandsRaised, maxWinners, remainingWinners);
                updateEvent.EventId = updateEventId;

                UpdateEventCommand updateCommand = new UpdateEventCommand(updateEvent);
                commandBus.Execute(updateCommand);


                List <String> updateImagePaths = ImagePathCreation();

                foreach (string path in updateImagePaths)
                {
                    InsertPictureCommand eventCommand = new InsertPictureCommand(new Picture(0, path, updateEvent.EventId));
                    commandBus.Execute(eventCommand);
                }

                return(updateEvent);
            }

            Event newEvent = ConvertToEvent(eventVenue, eventName, enteredDate, enteredTicketQuantity, enteredMaxClaims, categoryId,
                                            datePosted, postStatus, eventDescription, totalHandsRaised, maxWinners, remainingWinners);
            InsertEventCommand command = new InsertEventCommand(newEvent);

            commandBus.Execute(command, delegate(Event result) { newEvent = result; });

            List <String> imagePaths = ImagePathCreation();

            foreach (string path in imagePaths)
            {
                InsertPictureCommand eventCommand = new InsertPictureCommand(new Picture(0, path, newEvent.EventId));
                commandBus.Execute(eventCommand);
            }

            return(newEvent);
        }