public static void CreateShift(Shift shift) { if (shift == null) { throw new Exception(string.Format(_InvalidMessage, "Shift")); } Data.Provider.Shift_Insert(shift); }
public ViewResult Edit(Shift shift) { if (ModelState.IsValid) { Provider.UpdateShift(shift); return View("Index", Provider.GetShifts()); } else { return View(shift); } }
public void Shift_Update_Tests() { Shift shift1 = new Shift(); shift1.ShiftName = "Shift B"; shift1.ShiftAbbreviation = "ShB"; Provider.Shift_Insert(shift1); Shift shift2 = new Shift(); shift2.ShiftName = "Shift C"; shift2.ShiftAbbreviation = "Night"; Provider.Shift_Insert(shift2); DataSet table1 = Provider.Shift_SelectAll(); Assert.IsTrue(table1.Tables[0].Rows.Count > 2); Shift updateShift = new Shift(); updateShift.ShiftId = int.Parse(table1.Tables[0].Rows[0]["ShiftId"].ToString()); updateShift.ShiftName = table1.Tables[0].Rows[0]["ShiftName"].ToString(); updateShift.ShiftAbbreviation = table1.Tables[0].Rows[0]["ShiftAbbreviation"].ToString(); updateShift.ShiftName += " Changed"; string shiftName = updateShift.ShiftName; Provider.Shift_Update(updateShift); table1 = Provider.Shift_SelectAll(); updateShift = new Shift(); updateShift.ShiftId = int.Parse(table1.Tables[0].Rows[0]["ShiftId"].ToString()); updateShift.ShiftName = table1.Tables[0].Rows[0]["ShiftName"].ToString(); updateShift.ShiftAbbreviation = table1.Tables[0].Rows[0]["ShiftAbbreviation"].ToString(); Assert.IsTrue(updateShift.ShiftName == shiftName); Provider.Shift_Delete(shift1.ShiftId); Provider.Shift_Delete(shift2.ShiftId); }
public void Shift_SelectAll_Tests() { Shift shift1 = new Shift(); shift1.ShiftName = "Shift B"; shift1.ShiftAbbreviation = "ShB"; Provider.Shift_Insert(shift1); Shift shift2 = new Shift(); shift2.ShiftName = "Shift C"; shift2.ShiftAbbreviation = "Night"; Provider.Shift_Insert(shift2); DataSet table1 = Provider.Shift_SelectAll(); Assert.IsTrue(table1.Tables[0].Rows[0]["ShiftName"].ToString() == "Shift B"); Assert.IsTrue(table1.Tables[0].Rows[0]["ShiftAbbreviation"].ToString() == "ShB"); Assert.IsTrue(table1.Tables[0].Rows[1]["ShiftName"].ToString() == "Shift C"); Assert.IsTrue(table1.Tables[0].Rows[1]["ShiftAbbreviation"].ToString() == "Night"); Provider.Shift_Delete(shift1.ShiftId); Provider.Shift_Delete(shift2.ShiftId); }
public static void Shift_Update(Shift input) { SqlConnection connection = new SqlConnection(_ConnectionString); SqlCommand command = new SqlCommand("Shift_Update", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@ShiftId", input.ShiftId); command.Parameters.AddWithValue("@ShiftName", input.ShiftName); command.Parameters.AddWithValue("@ShiftAbbreviation", input.ShiftAbbreviation); SqlUtility.ExecuteNonQuery(command); }
public static void UpdateShift(Shift shift) { if (shift == null) { throw new Exception(string.Format(_InvalidMessage, "Shift")); } if (shift.ShiftId <= 0) { throw new Exception(string.Format(_InvalidIdMessage, "ShiftId")); } Data.Provider.Shift_Update(shift); }
public static List<Shift> GetShifts() { List<Shift> returnValue = new List<Shift>(); DataSet shiftDataset = Data.Provider.Shift_SelectAll(); foreach (DataRow row in shiftDataset.Tables[0].Rows) { Shift shift = new Shift(); shift.ShiftId = int.Parse(row["ShiftId"].ToString()); shift.ShiftName = row["ShiftName"].ToString(); shift.ShiftAbbreviation = row["ShiftAbbreviation"].ToString(); returnValue.Add(shift); } return returnValue; }
public static Shift GetShift(int shiftId) { Shift shift = new Shift(); DataSet shiftDataset = Data.Provider.Shift_SelectById(shiftId); shift.ShiftId = int.Parse(shiftDataset.Tables[0].Rows[0]["ShiftId"].ToString()); shift.ShiftName = shiftDataset.Tables[0].Rows[0]["ShiftName"].ToString(); shift.ShiftAbbreviation = shiftDataset.Tables[0].Rows[0]["ShiftAbbreviation"].ToString(); return shift; }