public ActionResult Create(CreateVolunteerFormViewModel model, string id) { if (model != null && ModelState.IsValid) { model.Other = this.sanitizeService.Sanitize(model.Other); var newVolunteerForm = AutoMapper.Mapper.Map <VolunteerForm>(model); newVolunteerForm.OrganizationId = id; newVolunteerForm.Organization = organizations.GetById(id).FirstOrDefault(); newVolunteerForm.UserId = this.User.Identity.GetUserId(); newVolunteerForm.User = adopters.GetById(newVolunteerForm.UserId).FirstOrDefault(); this.volunteers.AddNew(newVolunteerForm); return(this.RedirectToAction("Index", "Home", new { area = "" })); } else { return(this.View(model)); } }
public ActionResult Create(CreateVolunteerFormViewModel model, string id) { if (model != null && ModelState.IsValid) { model.Other = this.sanitizeService.Sanitize(model.Other); var newVolunteerForm = AutoMapper.Mapper.Map<VolunteerForm>(model); newVolunteerForm.OrganizationId = id; newVolunteerForm.Organization = organizations.GetById(id).FirstOrDefault(); newVolunteerForm.UserId = this.User.Identity.GetUserId(); newVolunteerForm.User = adopters.GetById(newVolunteerForm.UserId).FirstOrDefault(); this.volunteers.AddNew(newVolunteerForm); return this.RedirectToAction("Index", "Home", new { area = "" }); } else { return this.View(model); } }