Ejemplo n.º 1
0
        public ActionResult PickAttendees(string activityId, string accountId, FormCollection form)
        {
            var activityRepository = new ActivityRepository();
            Activity activity = activityRepository.GetById(activityId);

            var accountRepository = new AccountRepository();
            Account account = accountRepository.GetById(accountId);

            Meeting meeting = activity.Meetings.Where(m => m.Id == Guid.Parse(form["meeting.Id"])).FirstOrDefault();
            if (meeting == null) return View("Error");

            AttendeeViewModel vm;

            var attendee = account.FindAttendeeForActivity(activity);

            if (attendee == null)
            {
                vm = new AttendeeViewModel
                {
                    Account = Mapper.Map(account, new AccountViewModel()),
                    Meeting = Mapper.Map(meeting, new MeetingViewModel())
                };

                vm.BuildDefaultChildren();
            }
            else
            {
                attendee.Meeting = meeting;

                vm = Mapper.Map(attendee, new AttendeeViewModel());
            }

            return View(vm);
        }