public ActionResult DeleteConfirmed(int id) { RegisterDonor registerDonor = db.RegisterDonors.Find(id); db.RegisterDonors.Remove(registerDonor); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,Address,Occupation,Dob,Sex,Phone,State,LGA,RepPerson,BloodGroup,LastDonated")] RegisterDonor registerDonor) { if (ModelState.IsValid) { db.Entry(registerDonor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(registerDonor)); }
// GET: RegisterDonors/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RegisterDonor registerDonor = db.RegisterDonors.Find(id); if (registerDonor == null) { return(HttpNotFound()); } return(View(registerDonor)); }
public RegisterDonorViewModel(RegisterDonor donor) { Id = donor.Id; Name = donor.Name; Address = donor.Address; Occupation = donor.Occupation; Dob = donor.Dob; Sex = donor.Sex; //PO = donor.PO; State = donor.State; LGA = donor.LGA; Phone = donor.Phone; RepPerson = donor.RepPerson; BloodGroup = donor.BloodGroup; LastDonated = donor.LastDonated; }
/// <summary> /// Registers new Donor /// </summary> /// <param name="pesel">Can't be already taken.</param> /// <param name="name"></param> /// <param name="bloodType"></param> /// <param name="mail"></param> /// <param name="phone"></param> /// <exception cref="ResouceAlreadyExistsException"> /// Thrown when donor with that pesel already exists. /// </exception> /// <exception cref="UserNotLoggedInException"> /// Thrown when user is not logged in. /// </exception> public async Task RegisterDonorAsync(string pesel, string name, BloodType bloodType, string mail, string phone) { var registerDonor = new RegisterDonor(pesel, name, bloodType, mail, phone); var registerDonorJson = JsonConvert.SerializeObject(registerDonor); var response = await Client.AuthenticatedPostJsonAsync("personnel/newDonor", new StringContent(registerDonorJson), Token); switch (response.StatusCode) { case HttpStatusCode.Unauthorized: throw new UserNotLoggedInException(); case HttpStatusCode.Conflict: throw new ResouceAlreadyExistsException(response.ReasonPhrase); } }
public async Task <IActionResult> NewDonor([FromBody] RegisterDonor registerDonor) { if (registerDonor == null) { return(BadRequest("New donor can't be null")); } var password = registerDonor.Pesel; try { await donorService.RegisterAsync(registerDonor.Pesel, registerDonor.Name, registerDonor.BloodType, registerDonor.Mail, registerDonor.Phone, password); } catch (UserAlreadyExistsException e) { return(StatusCode(409, e.Message)); } return(Created($"personnel/donor/{registerDonor.Pesel}", Json(registerDonor))); }
public ActionResult Save(RegisterDonor donor) { if (!ModelState.IsValid) { var viewModel = new RegisterDonorViewModel { RegisterDonor = donor }; return(View("RegisterDonor", viewModel)); } if (donor.Id == 0) { _context.RegisterDonors.Add(donor); } _context.SaveChanges(); TempData["Message"] = "Your data " + donor.Name + "has been saved successfully"; return(RedirectToAction("RegisterDonor")); //return RedirectToAction("Index", "Home"); }