public void EditWaiterTest() { if (waiterContext1 == null) { AddNewWaiterTest(); } ManagerLogInTest(); waiterContext1.LastName = waiterEditedLastName1; bool result = managerDataAccess.EditWaiter(managerContext1.Id, waiterContext1); Assert.IsTrue(result); var waiters = managerDataAccess.GetWaiters(managerContext1.Id); Assert.IsTrue(waiters != null || waiters.Any()); var editedWaiter = waiters.FirstOrDefault(w => w.Id == waiterContext1.Id); Assert.IsNotNull(editedWaiter); Assert.AreEqual(editedWaiter.LastName, waiterEditedLastName1); ManagerLogOutTest(); }
public bool EditWaiter(UserContext waiter, string login, string firstName, string lastName, string password) { bool result; var oldLogin = waiter.Login; var oldFirstName = waiter.FirstName; var oldSecondName = waiter.LastName; //var oldPassword = waiter.Password; waiter.Login = login; waiter.FirstName = firstName; waiter.LastName = lastName; //waiter.Password = password; try { result = _managerDataAccess.EditWaiter(waiter); } catch { waiter.Login = oldLogin; waiter.FirstName = oldFirstName; waiter.LastName = oldSecondName; //waiter.Password = oldPassword; throw new Exception("Exception from DB"); } if (!result) { waiter.Login = oldLogin; waiter.FirstName = oldFirstName; waiter.LastName = oldSecondName; //waiter.Password = oldPassword; } return(result); }