Exemple #1
0
        public ActionResult Edit(EditDinnerCommand editDinnerCommand)
        {
            var dinnerId = editDinnerCommand.DinnerId;
            var dinner   = dinnerReadModel.GetDinnerById(dinnerId);

            if (!dinnerReadModel.DinnerIsHostedBy(dinnerId, User.Identity.Name))
            {
                return(View("InvalidOwner"));
            }

            try
            {
                var dinnerHost = new DinnerHost();
                var location   = new Location();
                UpdateModel(dinnerHost);
                UpdateModel(location);

                editDinnerCommand.Host     = dinnerHost;
                editDinnerCommand.Location = location;
                commandService.EditDinner(editDinnerCommand);
                TempData["Dinner"] = dinner;
                return(RedirectToAction("Details", new { id = dinner.DinnerId }));
            }
            catch
            {
                return(View(dinner));
            }
        }
Exemple #2
0
        public void Edit(DateTime newEventDate, string newTitle, string newDescription, string newContactPhone,
                         DinnerHost newDinnerHost, Location newLocation)
        {
            if (title != newTitle || description != newDescription)
            {
                Apply(new DinnerChangedEvent {
                    NewTitle = newTitle, NewDescription = newDescription, PreviousTitle = title, PreviousDescription = description
                });
            }

            if (eventDate != newEventDate)
            {
                Apply(new DinnerEventDateChangedEvent {
                    NewEventDate = newEventDate, PreviousEventDate = eventDate
                });
            }

            if (contactPhone != newContactPhone)
            {
                Apply(new DinnerContactPhoneChangedEvent {
                    NewContactPhone = newContactPhone, PreviousContactPhone = contactPhone
                });
            }

            if (!dinnerHost.Equals(newDinnerHost))
            {
                Apply(new DinnerHostChangedEvent {
                    HostedById = newDinnerHost.HostedById, HostedBy = newDinnerHost.HostedBy
                });
            }

            if (!location.Equals(newLocation))
            {
                Apply(new DinnerLocationChangedEvent {
                    Address = location.Address, Country = location.Country, Latitude = location.Latitude, Longitude = location.Longitude
                });
            }
        }
Exemple #3
0
 public Dinner(Guid dinnerId, DateTime eventDate, string title, string description, string contactPhone, DinnerHost host, Location location)
 {
     Apply(new DinnerCreatedEvent
     {
         DinnerId     = dinnerId,
         DinnerDate   = eventDate,
         Title        = title,
         Description  = description,
         ContactPhone = contactPhone
     });
     Apply(new DinnerLocationSetEvent
     {
         Address   = location.Address,
         Country   = location.Country,
         Latitude  = location.Latitude,
         Longitude = location.Longitude
     });
     Apply(new DinnerHostAssignedEvent {
         HostedById = host.HostedById, HostedBy = host.HostedBy
     });
     Apply(new DinnerRsvpAddedEvent {
         AttendeeId = host.HostedById, AttendeeName = host.HostedBy
     });
 }
Exemple #4
0
 protected void OnDinnerHostAssigned(DinnerHostAssignedEvent domainEvent)
 {
     dinnerHost = new DinnerHost {
         HostedBy = domainEvent.HostedBy, HostedById = domainEvent.HostedById
     };
 }