public IActionResult Add(AttendeeEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Please check input"));
            }

            // Add to db
            _attendeeService.Add(model, User.Identity.Name);

            // Ensure an entry for this attendee doesn't already exist
            //if (!_attendeeService.Exists(model.FirstName, model.LastName, model.MiddleName))
            //    _attendeeService.Add(model, User.Identity.Name);
            //else
            //    return BadRequest($"Attendee {model.FirstName} {model.MiddleName} {model.LastName} already exists.");

            return(Ok());
        }
        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);
        }
Beispiel #3
0
        public ActionResult Add(AttendeeEditModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Agencies = _agencyService.GetAgencies(1, 50);
                return(View(model));
            }

            // Ensure attendee doesn't already exist
            if (_attendeeService.Exists(model.FirstName, model.LastName, model.MiddleName))
            {
                ModelState.AddModelError("", "An attendee with that name already exists.");
                model.Agencies = _agencyService.GetAgencies(1, 50);
                return(View(model));
            }

            // Add attendee to db
            _attendeeService.Add(model, User.Identity.Name);

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #4
0
 public void Add(AttendeeDto attendee)
 {
     attendeeService.Add(attendee);
 }