public void Dispatcher_SelectAll_Tests() { Dispatcher dispatcher1 = new Dispatcher(); dispatcher1.DispatcherId = "1234www"; dispatcher1.FirstName = "Eric"; dispatcher1.LastName = "Fayad"; dispatcher1.RoleTypeId = 1; Provider.Dispatcher_Insert(dispatcher1); Dispatcher dispatcher2 = new Dispatcher(); dispatcher2.DispatcherId = "5678www"; dispatcher2.FirstName = "Christian"; dispatcher2.LastName = "Maggiora"; dispatcher2.RoleTypeId = 2; Provider.Dispatcher_Insert(dispatcher2); DataSet table1 = Provider.Dispatcher_SelectAll(); Assert.IsTrue(table1.Tables[0].Rows[0]["DispatcherId"].ToString() == "1234www"); Assert.IsTrue(table1.Tables[0].Rows[0]["FirstName"].ToString() == "Eric"); Assert.IsTrue(table1.Tables[0].Rows[0]["LastName"].ToString() == "Fayad"); Assert.IsTrue(table1.Tables[0].Rows[0]["RoleTypeId"].ToString() == "1"); Assert.IsTrue(table1.Tables[0].Rows[1]["DispatcherId"].ToString() == "5678www"); Assert.IsTrue(table1.Tables[0].Rows[1]["FirstName"].ToString() == "Christian"); Assert.IsTrue(table1.Tables[0].Rows[1]["LastName"].ToString() == "Maggiora"); Assert.IsTrue(table1.Tables[0].Rows[1]["RoleTypeId"].ToString() == "2"); Provider.Dispatcher_Delete(dispatcher1.DispatcherId); Provider.Dispatcher_Delete(dispatcher2.DispatcherId); }
public void Dispatcher_Tests() { Dispatcher dispatcher1 = new Dispatcher(); dispatcher1.DispatcherId = "1234lop"; dispatcher1.FirstName = "Eric"; dispatcher1.LastName = "Fayad"; dispatcher1.RoleTypeId = 1; Provider.CreateDispatcher(dispatcher1); Dispatcher dispatcher2 = new Dispatcher(); dispatcher2.DispatcherId = "543opt"; dispatcher2.FirstName = "Christian"; dispatcher2.LastName = "Maggiora"; dispatcher2.RoleTypeId = 2; Provider.CreateDispatcher(dispatcher2); List<Dispatcher> dispatcherList = Provider.GetDispatchers(); dispatcher1 = GetDispatcher(dispatcher1.DispatcherId, dispatcherList); Assert.IsTrue(dispatcherList.Contains(dispatcher1)); dispatcher2 = GetDispatcher(dispatcher2.DispatcherId, dispatcherList); Assert.IsTrue(dispatcherList.Contains(dispatcher2)); dispatcher1.FirstName = "Bob"; Provider.UpdateDispatcher(dispatcher1); dispatcherList = Provider.GetDispatchers(); dispatcher1 = dispatcherList[0]; Assert.IsFalse(dispatcher1.FirstName == "Eric"); Provider.DeleteDispatcher(dispatcher1.DispatcherId); Provider.DeleteDispatcher(dispatcher2.DispatcherId); }
public static void CreateDispatcher(Dispatcher dispatcher) { if (dispatcher == null) { throw new Exception(string.Format(_InvalidMessage, "Dispatcher")); } if (dispatcher.DispatcherId == null) { throw new Exception(string.Format(_InvalidIdMessage, "DispatcherId")); } Data.Provider.Dispatcher_Insert(dispatcher); }
public ViewResult Edit(Dispatcher dispatcher) { //TODO: If we're going from a non-dispatcher role to a dispatcher, we should set IsValid = false for any login credentials this person has //And Vice-Versa if (ModelState.IsValid) { Provider.UpdateDispatcher(dispatcher); return View("Index", GetDispatcherViewModels()); } else { DispatcherViewModel model = GetDispatcherViewModelFrom(dispatcher); model.RoleTypeDropDown = DropDownUtility.GetRoleTypeDropDown(); return View(model); } }
public void Dispatcher_SelectById_Tests() { //Insert a new row Dispatcher dispatcher1 = new Dispatcher(); dispatcher1.DispatcherId = "1234www"; dispatcher1.FirstName = "Eric"; dispatcher1.LastName = "Fayad"; dispatcher1.RoleTypeId = 1; Provider.Dispatcher_Insert(dispatcher1); DataSet table1 = Provider.Dispatcher_SelectById(dispatcher1.DispatcherId); Provider.Dispatcher_Delete(dispatcher1.DispatcherId); Assert.IsTrue(table1.Tables[0].Rows[0]["DispatcherId"].ToString() == "1234www"); Assert.IsTrue(table1.Tables[0].Rows[0]["FirstName"].ToString() == "Eric"); Assert.IsTrue(table1.Tables[0].Rows[0]["LastName"].ToString() == "Fayad"); Assert.IsTrue(table1.Tables[0].Rows[0]["RoleTypeId"].ToString() == "1"); //Insert another row //Select all //Loop through each and make sure all the fields are what they should be //Update one //Select that one by ID and make sure all of the fields are what they should be //Clean up by deleting both of the guys }
public void Dispatcher_Update_Tests() { Dispatcher dispatcher1 = new Dispatcher(); dispatcher1.DispatcherId = "1234www"; dispatcher1.FirstName = "Eric"; dispatcher1.LastName = "Fayad"; dispatcher1.RoleTypeId = 1; Provider.Dispatcher_Insert(dispatcher1); //selectbyid into a dataset and make sure firstname is Eric DataSet table1 = Provider.Dispatcher_SelectById(dispatcher1.DispatcherId); Assert.IsTrue(table1.Tables[0].Rows[0]["FirstName"].ToString() == "Eric"); //selectbyid into the same dataset (not a new one) and make sure firstname is Bob dispatcher1.FirstName = "Bob"; Provider.Dispatcher_Update(dispatcher1); table1 = Provider.Dispatcher_SelectById(dispatcher1.DispatcherId); Assert.IsTrue(table1.Tables[0].Rows[0]["FirstName"].ToString() == "Bob"); //Delete dispatcher 1234www Provider.Dispatcher_Delete(dispatcher1.DispatcherId); table1 = Provider.Dispatcher_SelectById(dispatcher1.DispatcherId); Assert.IsTrue(table1.Tables[0].Rows.Count == 0); }
internal static DispatcherViewModel GetDispatcherViewModelFrom(Dispatcher dispatcher) { DispatcherViewModel returnValue = new DispatcherViewModel(); returnValue.DispatcherId = dispatcher.DispatcherId; returnValue.FirstName = dispatcher.FirstName; returnValue.LastName = dispatcher.LastName; returnValue.RoleTypeId = dispatcher.RoleTypeId; returnValue.RoleTypeDescription = GetRoleTypeDescription(dispatcher.RoleTypeId, Provider.GetRoles()); return returnValue; }
public static void Dispatcher_Insert(Dispatcher input) { SqlConnection connection = new SqlConnection(_ConnectionString); SqlCommand command = new SqlCommand("Dispatcher_Insert", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@DispatcherId", input.DispatcherId); command.Parameters.AddWithValue("@FirstName", input.FirstName); command.Parameters.AddWithValue("@LastName", input.LastName); command.Parameters.AddWithValue("@RoleTypeId", input.RoleTypeId); SqlUtility.ExecuteNonQuery(command); }
public static List<Dispatcher> GetDispatchers() { List<Dispatcher> returnValue = new List<Dispatcher>(); DataSet dispatcherDataSet = Data.Provider.Dispatcher_SelectAll(); foreach (DataRow row in dispatcherDataSet.Tables[0].Rows) { Dispatcher dispatcher = new Dispatcher(); dispatcher.DispatcherId = row["DispatcherId"].ToString(); dispatcher.FirstName = row["FirstName"].ToString(); dispatcher.LastName = row["LastName"].ToString(); dispatcher.RoleTypeId = int.Parse(row["RoleTypeId"].ToString()); returnValue.Add(dispatcher); } return returnValue; }
public static Dispatcher GetDispatcherByUsername(string username) { Dispatcher returnValue = new Dispatcher(); DataSet dispatcherDataSet = Data.Provider.Dispatcher_SelectByUsername(username); returnValue.DispatcherId = dispatcherDataSet.Tables[0].Rows[0]["DispatcherId"].ToString(); returnValue.FirstName = dispatcherDataSet.Tables[0].Rows[0]["FirstName"].ToString(); returnValue.LastName = dispatcherDataSet.Tables[0].Rows[0]["LastName"].ToString(); returnValue.RoleTypeId = int.Parse(dispatcherDataSet.Tables[0].Rows[0]["RoleTypeId"].ToString()); return returnValue; }
public static Dispatcher GetDispatcher(string dispatcherId) { Dispatcher returnValue = null; DataSet dispatcherDataSet = Data.Provider.Dispatcher_SelectById(dispatcherId); if (dispatcherDataSet.Tables[0].Rows.Count > 0) { returnValue = new Dispatcher(); returnValue.DispatcherId = dispatcherDataSet.Tables[0].Rows[0]["DispatcherId"].ToString(); returnValue.FirstName = dispatcherDataSet.Tables[0].Rows[0]["FirstName"].ToString(); returnValue.LastName = dispatcherDataSet.Tables[0].Rows[0]["LastName"].ToString(); returnValue.RoleTypeId = int.Parse(dispatcherDataSet.Tables[0].Rows[0]["RoleTypeId"].ToString()); } return returnValue; }