Exemplo n.º 1
0
        public ActionResult Index(string id)
        {
            var vm = new AttendeeViewModel(id);

            vm.HandleRequest();
            return(View(vm));
        }
Exemplo n.º 2
0
        public ActionResult IndexAdmin(string id, bool role)
        {
            var vm = new AttendeeViewModel(id, role);

            vm.HandleRequest();
            return(View("Index", vm));
        }
        /// <summary>
        /// The attendee details.
        /// </summary>
        /// <param name="attendeeId">
        /// The attendee id.
        /// </param>
        /// <param name="eventId">
        /// The event id.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult AttendeeDetails(string attendeeId, string eventId)
        {
            Attendee attendeeDetails = AttendeesService.GetAttendeeDetailsByEventsIdAndAttendeeId(eventId, attendeeId);

            AttendeeViewModel viewModel = new AttendeeViewModel(attendeeDetails);

            return(this.View(viewModel));
        }
        public ActionResult Create(string eventName)
        {
            var viewModel = new AttendeeViewModel()
            {
                EventName = eventName
            };

            return(View(viewModel));
        }
Exemplo n.º 5
0
 public ActionResult Index(AttendeeViewModel vm)
 {
     vm.HandleRequest();
     // NOTE: Must clear the model state in order to bind
     //       the @Html helpers to the new model values
     ModelState.Clear();
     return(View(vm));
     // return View(vm);
 }
Exemplo n.º 6
0
        public ActionResult Register()
        {
            var viewModel = new AttendeeViewModel
            {
                Clients = _context.Clients.ToList()
            };

            return(View(viewModel));
        }
Exemplo n.º 7
0
        public async Task <ActionResult> Edit(int meetingId, int attendeeId, [FromForm] AttendeeViewModel model)
        {
            var memberClient = new MemberClient(_config);
            var members      = await memberClient.GetAll();

            if (ModelState.IsValid)
            {
                try
                {
                    var client = new MeetingClient(_config);

                    var attendee = await client.GetAttendee(meetingId, attendeeId);

                    if (null == attendee)
                    {
                        return(NotFound());
                    }

                    if (null == model.MemberId)
                    {
                        attendee.Member = null;
                    }
                    else
                    {
                        attendee.Member = await memberClient.Get(model.MemberId.Value);

                        // Keep only the member alias
                        attendee.Member.Name = attendee.Member.Alias;
                    }

                    var response = await client.UpdateAttendee(meetingId, attendee);

                    if (response.IsSuccessStatusCode)
                    {
                        _toastNotification.AddSuccessToastMessage($"Le participant a été modifiée.");

                        return(RedirectToAction("Details", "Meetings", new { Id = meetingId }));
                    }
                }
                catch
                {
                    model.Members = members.Select(p => new SelectListItem {
                        Value = p.Id.ToString(), Text = p.Alias
                    }).ToList();

                    return(View(model));
                }
            }

            model.Members = members.Select(p => new SelectListItem {
                Value = p.Id.ToString(), Text = p.Alias
            }).ToList();

            return(View(model));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Get(string username)
        {
            await _apiClient.GetAttendeeAsync(username);

            var vm = new AttendeeViewModel()
            {
                UserName = username
            };

            return(View("Index", vm));
        }
        public AttendeeViewModel Update(AttendeeViewModel atendeeViewModel)
        {
            var atendee = Mapper.Map <Attendee>(atendeeViewModel);

            //Must be improved
            if (atendee.IsValid())
            {
                _atendeeRepository.Update(atendee);
            }

            atendeeViewModel = Mapper.Map <AttendeeViewModel>(atendee);
            return(atendeeViewModel);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets attendee by Id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AttendeeViewModel Get(int id)
        {
            var attendeeViewModel = new AttendeeViewModel();

            var attendee = _attendeeRepo.Get(id);

            if (attendee != null)
            {
                attendeeViewModel = _mapper.Map <AttendeeViewModel>(attendee);
            }

            return(attendeeViewModel);
        }
Exemplo n.º 11
0
        public static void AddAttendee(AttendeeViewModel collection, string userName)
        {
            // Get an instance of the DB
            var options = new Microsoft.EntityFrameworkCore.DbContextOptions <ApplicationDbContext>();

            using (var db = new ApplicationDbContext(options))
            {
                var userData       = db.UserData.FirstOrDefault(u => u.UserName == userName);
                var eventViewModel = userData.Events.FirstOrDefault(e => e.Name == collection.EventName);
                eventViewModel.Attendees.Add(collection);

                db.SaveChanges();
            }
        }
Exemplo n.º 12
0
        public ActionResult Edit(AttendeeViewModel atendeeViewModel)
        {
            if (ModelState.IsValid)
            {
                atendeeViewModel = _atendeeAppService.Update(atendeeViewModel);
                if (atendeeViewModel.ValidationResult.IsValid)
                {
                    return(RedirectToAction("Index"));
                }

                AddErrorIntoModelState(atendeeViewModel.ValidationResult);
            }
            return(View(atendeeViewModel));
        }
Exemplo n.º 13
0
        public ActionResult Create(AttendeeViewModel attendeeViewModel)
        {
            try
            {
                // add attendee to the event
                Data.AddAttendee(attendeeViewModel, this.User.Identity.Name);

                // Add another
                return(RedirectToAction("Create", "Attendee", new { @eventName = attendeeViewModel.EventName }));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 14
0
        public AttendeeViewModel Add(AttendeeViewModel atendeeViewModel)
        {
            var atendee = Mapper.Map <Attendee>(atendeeViewModel);

            atendee.Activate();

            var atendeeRet = _atendeeService.Add(atendee);

            if (atendeeRet.validationResult.IsValid)
            {
                if (!Commit())
                {
                    //Either get an error or throw an error.
                }
            }

            atendeeViewModel = Mapper.Map <AttendeeViewModel>(atendeeRet);
            return(atendeeViewModel);
        }
        public AttendeeDetailsPage(AttendeeViewModel attendee, bool inEditMode = false)
        {
            InitializeComponent();

            Title = "Attendee Details";
            SetValue(NavigationPage.BarBackgroundColorProperty, Color.FromHex("#52004C"));

            // set dropdown values
            cmbGender.ItemsSource   = Constants.Genders;
            cmbSeatType.ItemsSource = Constants.SeatTypes;

            // initialize stuff
            _attendanceClient = new AttendanceClient();
            SetAttendeeDisplayValue(attendee);

            if (inEditMode)
            {
                ShowEditControls();
            }
        }
Exemplo n.º 16
0
        public async Task <ActionResult> Edit(int meetingId, int attendeeId)
        {
            var client   = new MeetingClient(_config);
            var attendee = await client.GetAttendee(meetingId, attendeeId);

            if (null == attendee)
            {
                return(NotFound());
            }

            var model = new AttendeeViewModel
            {
                Id        = attendeeId,
                MeetingId = meetingId,
                RoleId    = attendee.Role.Id,
                RoleName  = attendee.Role.Name
            };

            if (null == attendee.Member)
            {
                model.MemberId = null;
            }
            else
            {
                model.MemberId = attendee.Member.Id;
            }

            var memberClient = new MemberClient(_config);
            var members      = await memberClient.GetAll();

            model.Members = members.Select(p => new SelectListItem {
                Value = p.Id.ToString(), Text = p.Alias
            }).ToList();

            return(View(model));
        }
Exemplo n.º 17
0
        public ActionResult Register(AttendeeViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Clients = _context.Clients.ToList();
                return(View("Register", viewModel));
            }

            var client = _context.Clients.Single(c => c.Id == viewModel.Client);

            var attendee = new Attendee
            {
                FirstName = viewModel.FirstName,
                LastName  = viewModel.LastName,
                Email     = viewModel.Email,
                DateTime  = DateTime.Now,
                Client    = client
            };

            _context.Attendees.Add(attendee);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
 private void SetAttendeeDisplayValue(AttendeeViewModel attendee)
 {
     BindingContext = attendee;
 }
Exemplo n.º 19
0
 public async Task SendMessage(AttendeeViewModel attendee)
 {
     await Clients.All.SendAsync("messageReceived", attendee);
 }
Exemplo n.º 20
0
        public async Task <IActionResult> Post(AttendeeViewModel model)
        {
            await _apiClient.AddAttendeeAsync(model.AsDto());

            return(RedirectToAction("Index"));
        }