/// <summary> /// Update attendee data /// </summary> /// <param name="attendeeEditModel"></param> public void Update(AttendeeEditModel attendeeEditModel, string username) { var attendee = _mapper.Map <Attendee>(attendeeEditModel); // Set mod user and date attendee.ModUser = username; attendee.ModDate = DateTime.Now; // Get existing record from db var dbAttendee = _attendeeRepo.Get(attendee.Id); if (dbAttendee != null) { // Copy Rec user and date attendee.RecUser = dbAttendee.RecUser; attendee.RecDate = dbAttendee.RecDate; // If no Cert ID given, copy existing from db if (string.IsNullOrEmpty(attendee.CertId)) { attendee.CertId = dbAttendee.CertId; } // Update db record _attendeeRepo.Update(attendee); } else { // Throw because we don't have an existing record throw new Exception("Could not update attendee. Attendee not found."); } }
// Add Attenddee : Get public ActionResult Add(int p = 1, int ps = 50) { StorePaging(p, ps); var model = new AttendeeEditModel(); model.Agencies = _agencyService.GetAgencies(1, 50); return(View(model)); }
public ActionResult Register(AttendeeEditModel model) { if (ModelState.IsValid) { var entity = _repository.GetById(model.ConferenceId); var attendee = new Attendee(model.FirstName, model.LastName) { Email = model.Email }; attendee.RegisterFor(entity); return(RedirectToAction("AttendeeConfirmation", model)); } return(View(model)); }
/// <summary> /// Add new attendee /// </summary> /// <param name="attendeeEditModel"></param> public void Add(AttendeeEditModel attendeeEditModel, string username) { var attendee = _mapper.Map <Attendee>(attendeeEditModel); // Set rec user and date attendee.RecUser = username; attendee.RecDate = DateTime.Now; // CertId: Get new random CertId if no id given if (string.IsNullOrEmpty(attendee.CertId)) { attendee.CertId = GetCertId(); } _attendeeRepo.Add(attendee); }
/// <summary> /// Gets the attendee and a list of all agencies. /// </summary> /// <param name="id"></param> /// <returns></returns> public AttendeeEditModel GetForEdit(int id) { var attendeeEditModel = new AttendeeEditModel(); var attendee = _attendeeRepo.Get(id); if (attendee != null) { attendeeEditModel = _mapper.Map <AttendeeEditModel>(attendee); // Get the agencies var agencies = _agencyRepo.GetEntities(1, 100); // update attendeeEditModel.Agencies = _mapper.MapList <Agency, AgencyViewModel>(agencies); } return(attendeeEditModel); }
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 ActionResult Update(AttendeeEditModel model, string ra = "Index") { if (!ModelState.IsValid) { model.Agencies = _agencyService.GetAgencies(1, 100); return(View(model)); } // Save changes to db _attendeeService.Update(model, User.Identity.Name); if (ra == "Details") { return(RedirectToAction(nameof(Details), new { id = model.Id })); } return(RedirectToAction(nameof(Index))); }
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))); }
public ActionResult AttendeeConfirmation(AttendeeEditModel model) { return(View(model)); }