public string Save(ClassRoomAllocation aClassRoom) { if (aClassRoom.Fromtime >= aClassRoom.Totime) { return("End Time Must Be Grater Than Start Time!"); } else { bool isTimeScheduleValid = IsTimeScheduleValid(aClassRoom.RoomId, aClassRoom.DayId, aClassRoom.Fromtime, aClassRoom.Totime); if (isTimeScheduleValid != true) { if (classRoomGateway.Save(aClassRoom) > 0) { return("Class Allocated Sucessfully!"); } else { return("Class Allocation Failed... Please Try Again"); } } else { return("Class Overlapping Is Invalid"); } } }
public string Save(ClassRoomAllocate aClassRoomAllocate) { if (TimeIsExist(aClassRoomAllocate) >= 1) { return("This Schedule is Already Booked "); } if (aClassRoomGateway.Save(aClassRoomAllocate) > 0) { return("Class Room Allocation Successfully Done"); } else { return("Failed"); } }
public string Save(ClassRoom classRoom) { if (classRoomGateway.CheckSlot(classRoom) && classRoomGateway.CheckSlot2(classRoom)) { return("Slot already Booked"); } else { if (classRoomGateway.Save(classRoom) > 0) { return("Saved"); } else { return("Not saved"); } } }
public string Save(ClassRoomAllocation classRoomAllocation) { List <ClassRoomAllocation> classRoomAllocations = classRoomGateway.GetClassRoomAllocationInfo(classRoomAllocation.RoomID, classRoomAllocation.Day); //int rowAffected = classRoomGateway.Save(classRoomAllocation); if (classRoomAllocations.Count == 0) { int rowAffected = classRoomGateway.Save(classRoomAllocation); if (rowAffected > 0) { return("Success"); } else { return("Failed."); } } else { string fromTime = classRoomAllocation.FromTimeHour + " " + classRoomAllocation.FromTimePeriod; string toTime = classRoomAllocation.ToTimeHour + " " + classRoomAllocation.ToTimePeriod; string dateFormat = "h:mm tt"; DateTime fromDateTime = DateTime.ParseExact(fromTime, dateFormat, CultureInfo.InvariantCulture); DateTime toDateTime = DateTime.ParseExact(toTime, dateFormat, CultureInfo.InvariantCulture); bool roomCanBeAllocated = true; foreach (ClassRoomAllocation classRoom in classRoomAllocations) { DateTime fromTimeAgainstWhichChekingToBeDone = DateTime.ParseExact(classRoom.FromTime, dateFormat, CultureInfo.InvariantCulture); DateTime toTimeAgainstWhichChekingToBeDone = DateTime.ParseExact(classRoom.ToTime, dateFormat, CultureInfo.InvariantCulture); if ((TimeSpan.Compare(fromTimeAgainstWhichChekingToBeDone.TimeOfDay, fromDateTime.TimeOfDay) == 1 && TimeSpan.Compare(fromTimeAgainstWhichChekingToBeDone.TimeOfDay, toDateTime.TimeOfDay) == 1) || (TimeSpan.Compare(toTimeAgainstWhichChekingToBeDone.TimeOfDay, fromDateTime.TimeOfDay) == -1 && TimeSpan.Compare(toTimeAgainstWhichChekingToBeDone.TimeOfDay, toDateTime.TimeOfDay) == -1)) { roomCanBeAllocated = true; } else { roomCanBeAllocated = false; } } if (roomCanBeAllocated) { int rowAffected = classRoomGateway.Save(classRoomAllocation); if (rowAffected > 0) { return("Success"); } else { return("Failed."); } } else { return("Room Can't be allocated."); } } }