public string SaveRoomAllocation(AllocationRoom allocationRoom) { if (allocationRoom.FromTime > allocationRoom.ToTime) { return("Start time can't be smaller "); } bool isTimeScheduleValid = IsTimeScheduleValid(allocationRoom.RoomId, allocationRoom.DayId, allocationRoom.FromTime, allocationRoom.ToTime); if (isTimeScheduleValid != true) { int rowsAffected = roomAllocationGateway.SaveRoomAlloaction(allocationRoom); if (rowsAffected > 0) { return("Saved Successful"); } else { return("Saved Failed"); } } else { return("Overlap time schedule"); } }
public List <AllocationRoom> GetClassSchedulByStartAndEndingTime(int roomId, int dayId, DateTime startTime, DateTime endTime) { Query = "Select * from RoomAllocations where RoomID='" + roomId + "' and DayID='" + dayId + "' "; Command = new SqlCommand(Query, Connection); Connection.Open(); Reader = Command.ExecuteReader(); List <AllocationRoom> roomAllocatinListList = new List <AllocationRoom>(); while (Reader.Read()) { AllocationRoom allocationRoom = new AllocationRoom { RoomAllocationId = (int)Reader["RoomAllocationID"], DepartmentId = (int)Reader["DepartmentID"], CourseId = (int)Reader["CourseID"], RoomId = (int)Reader["RoomID"], DayId = (int)Reader["DayID"], FromTime = (DateTime)Reader["FromTime"], ToTime = (DateTime)Reader["ToTime"], Time = Reader["Time"].ToString() }; roomAllocatinListList.Add(allocationRoom); } Reader.Close(); Connection.Close(); return(roomAllocatinListList); }
public int SaveRoomAlloaction(AllocationRoom allocationRoom) { allocationRoom.Time = Time(allocationRoom.FromTime, allocationRoom.ToTime); //allocationRoom.SheduleStatus = 1; Query = "INSERT INTO RoomAllocations (DepartmentID,CourseID,RoomID,DayID,FromTime,ToTime,Time) VALUES (@departmentId, @courseId,@roomId,@dayId,@fromTime,@toTime,@time)"; Command = new SqlCommand(Query, Connection); Command.Parameters.Clear(); Command.Parameters.AddWithValue("departmentId", allocationRoom.DepartmentId); Command.Parameters.AddWithValue("courseId", allocationRoom.CourseId); Command.Parameters.AddWithValue("roomId", allocationRoom.RoomId); Command.Parameters.AddWithValue("dayId", allocationRoom.DayId); Command.Parameters.AddWithValue("fromTime", allocationRoom.FromTime); Command.Parameters.AddWithValue("toTime", allocationRoom.ToTime); Command.Parameters.AddWithValue("time", allocationRoom.Time); //Command.Parameters.AddWithValue("scheduleStatus", allocationRoom.SheduleStatus); Connection.Open(); int rowsAffected = Command.ExecuteNonQuery(); Connection.Close(); return(rowsAffected); }
public ActionResult AllocateRoom(AllocationRoom allocationRoom) { ViewBag.SaveRooms = roomAllocationManager.SaveRoomAllocation(allocationRoom); ViewBag.Departments = departmentManager.GetAllDepartments(); ViewBag.Courses = courseManager.GetAllCourses(); ViewBag.Rooms = roomManager.GetAllRoom(); ViewBag.Days = roomManager.GetAllDays(); return(View()); }