public static QueryResult <Person> Update(Person person) { var response = new QueryResult <Person>(); try { var updatedPerson = PersonDAO.Update(person); if (updatedPerson != null) { response.Data = updatedPerson; } else { response.HasError = true; response.StatusCode = HttpStatusCode.NotFound; response.Message = $"The person with the ID {person.Id} does not exist in the database"; } } catch (Exception ex) { HandleError(response, ex); } return(response); }
public ActionResult Update(Person personUpdate) { var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); // Get the coordinates of the bar location that the user has given Tuple<double, double> tuple = GoogleGeoLocation.GetCoordinates(personUpdate.Address, personUpdate.City, personUpdate.State); // Set the remaining properties of the model returnedPerson.Lat = tuple.Item1; returnedPerson.Lng = tuple.Item2; returnedPerson.Name = personUpdate.Name; returnedPerson.Birthday = personUpdate.Birthday; returnedPerson.Address = personUpdate.Address; returnedPerson.City = personUpdate.City; returnedPerson.State = personUpdate.State; if (PersonDAO.Update(returnedPerson) != true) { ModelState.AddModelError("", "Error - Check information and try again"); return View("Account"); } return View("Account"); }
public void TestUpdate() { Insert(); dao.Update(2, new Person(2, "newbar", 66, 666.6)); Person p = dao.FindAll()[1]; Assert.AreEqual(2, p.Id); Assert.AreEqual("newbar", p.Name); Assert.AreEqual(66, p.Age); Assert.AreEqual(666.6, p.Wage); Clean(); }
public void TestUpdate() { Insert(); dao.Update(1, new Person(1, "newfoo", 66, 666.6)); var p = dao.FindById(1); Assert.AreEqual(1, p.Id); Assert.AreEqual(66, p.Age); Assert.AreEqual(666.6, p.Wage); Assert.AreEqual("newfoo", p.Name); Clean(); }
private static void Update() { Console.WriteLine("insert id, name, age, wage, active of Person to be updated : "); String input = Console.ReadLine(); try { String [] splitted = Regex.Split(input, "\\s*,\\s*"); Person p = SplittedToPerson(splitted); dao.Update(p.Id, p); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { long id = Convert.ToInt64(tbId.Text); string name = tbName.Text; int age = Convert.ToInt32(tbAge.Text); double wage = Convert.ToDouble(tbWage.Text); Person p = new CSharpApplication3.Person(id, name, age, wage); dao.Update(id, p); } catch (Exception ex) { lblStatus.Text = ex.Message; } finally { this.Dispose(); } }
public IActionResult Update(long id, Person person) { PersonDAO personDAO = new PersonDAO(_connection); var pOld = personDAO.FindByID(id); if (pOld == null) { return(NotFound()); } pOld.FirstName = person.FirstName; pOld.LastName = person.LastName; pOld.Email = person.Email; personDAO.Update(pOld); return(NoContent()); }
public ActionResult UpdatePhoto(HttpPostedFileBase upImage) { if (upImage == null) { ModelState.AddModelError("", "Error - Image dont work"); return View("Account"); } var returnedPerson = PersonDAO.Search(UserSession.ReturnPersonId(null)); if (returnedPerson == null) return RedirectToAction("Logout", "User"); returnedPerson.Photo = ImageHandler.HttpPostedFileBaseToByteArray(upImage); returnedPerson.PhotoType = upImage.ContentType; if (PersonDAO.Update(returnedPerson) != true) { ModelState.AddModelError("", "Error - Database update image error!"); return View("Account"); } return RedirectToAction("Account"); }
public void Update() { long id; string name; int age; double wage; Console.WriteLine("insert id , name, age, wage sep by comma: "); String input = Console.ReadLine(); String[] splitted = Regex.Split(input, "\\s*,\\s*"); try { id = Convert.ToInt64(splitted[0]); name = splitted[1]; age = Convert.ToInt32(splitted[2]); wage = Convert.ToDouble(splitted[3]); dao.Update(id, new Person(id, name, age, wage)); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public ActionResult Editar(Person person) { personDAO.Update(person); return(RedirectToAction("Index")); }