public ActionResult DeleteConfirm(string id) { string query = "select * from volunteerRecruitments inner join AspNetUsers on volunteerRecruitments.volunteer_id= AspNetUsers.id where AspNetUsers.id = @id"; SqlParameter param = new SqlParameter("@id", id); VolunteerRecruitment volunteer = db.volunteerRecruitment.SqlQuery(query, param).FirstOrDefault(); return(View(volunteer)); }
public ActionResult Show(string id) { string query = "select * from volunteerRecruitments inner join AspNetUsers on volunteerRecruitments.volunteer_id= AspNetUsers.id where AspNetUsers.id = @id"; var parameter = new SqlParameter("@id", id); Debug.WriteLine("-------------- " + query); VolunteerRecruitment volunteer = db.volunteerRecruitment.SqlQuery(query, parameter).FirstOrDefault(); return(View(volunteer)); }
public async Task <ActionResult> Add(string Username, string phoneNumber, string volunteerSpecialization, string Useremail, string Userpass) { Debug.WriteLine("Inside Post method add"); //christine pet groomer for reference ApplicationUser NewUser = new ApplicationUser(); NewUser.UserName = Username; NewUser.Email = Useremail; NewUser.PhoneNumber = phoneNumber; //code interpreted from AccountController.cs Register Method IdentityResult result = await UserManager.CreateAsync(NewUser, Userpass); if (result.Succeeded) { //we need to find the register user we just created -- get the ID of particular user string Id = NewUser.Id; //what was the id of the new account? //link this id to the Volunteer string volunteer_id = Id; string volunteer_status = "Waiting"; VolunteerRecruitment NewVol = new VolunteerRecruitment(); NewVol.volunteer_id = Id; NewVol.volunteer_specialization = volunteerSpecialization; NewVol.volunteer_status = volunteer_status; //LINQ //SQL equivalent : INSERT INTO volunteerRecruitment (volunteer_id, .. ) VALUES (@id..) db.volunteerRecruitment.Add(NewVol); db.SaveChanges(); return(RedirectToAction("List")); } else { //Simple way of displaying errors ViewBag.ErrorMessage = "Something Went Wrong!"; ViewBag.Errors = new List <string>(); foreach (var error in result.Errors) { ViewBag.Errors.Add(error); } } return(View()); }