public void Remove(AllocateClassRoomViewModel model) { if (model == null) { throw new ArgumentNullException("AllocateClassRoom"); } }
public string CheckTime(AllocateClassRoomViewModel aAllocateClassRoomViewModel) { AllocateClassRoomViewModel newAllocate = aAllocateClassRoomViewModel; IEnumerable <AllocateClassRoom> listInRooms = aUnitOfWork.Repository <AllocateClassRoom>() .GetList(x => x.RoomId == newAllocate.RoomId && x.DayId == newAllocate.DayId && x.IsAcTive == true).ToList(); if (newAllocate.From > newAllocate.To) { return("InValid"); } if (listInRooms.Count() == 0) { return("Ok"); } string msg = "Ok"; foreach (AllocateClassRoom oldAllocate in listInRooms) { DateTime oldForm = DateTime.Parse(oldAllocate.From); DateTime oldTo = DateTime.Parse(oldAllocate.To); if (newAllocate.From <= oldForm) { if (newAllocate.To > oldForm) { msg = "Full"; } } else if (newAllocate.From > oldForm && newAllocate.From < oldTo) { msg = "Full"; } //if (newAllocate.From>=oldForm && newAllocate.To<=oldTo) //{ // msg = "Full"; //} //else if (newAllocate.From <= oldForm && newAllocate.To >= oldTo) //{ // msg = "Full"; //} //else if(newAllocate.From>oldForm && newAllocate.From<oldTo) //{ // msg = "Full"; //} //else if(newAllocate.From<=oldForm && newAllocate.To<=oldTo) //{ // msg = "Full"; //} //else if (newAllocate.From <= oldForm && newAllocate.To > oldForm && newAllocate.To<oldTo) //{ // msg = "Full"; //} } return(msg); }
public string SaveAllocate(AllocateClassRoomViewModel aAllocateClassRoomViewModel) { string msg = CheckTime(aAllocateClassRoomViewModel); if (msg == "Full") { return("Class room is Full in this Time Zone"); } if (msg == "Ok") { AllocateClassRoom aAllocateClassRoom = new AllocateClassRoom(); aAllocateClassRoom.IsAcTive = true; aAllocateClassRoom.RoomId = aAllocateClassRoomViewModel.RoomId; aAllocateClassRoom.CourseId = aAllocateClassRoomViewModel.CourseId; aAllocateClassRoom.DayId = aAllocateClassRoomViewModel.DayId; aAllocateClassRoom.DepartmentId = aAllocateClassRoomViewModel.DepartmentId; string tempDate = aAllocateClassRoomViewModel.From.ToString("yyyy-MM-dd HH:mm:ss"); aAllocateClassRoom.From = tempDate; tempDate = aAllocateClassRoomViewModel.To.ToString("yyyy-MM-dd HH:mm:ss"); aAllocateClassRoom.To = tempDate; bool flag = aUnitOfWork.Repository <AllocateClassRoom>().InsertModel(aAllocateClassRoom); aUnitOfWork.Save(); return("Class Room allocated Succesfully"); } return("Class Room allocation failed, try some valid time"); }
public IActionResult Create(AllocateClassRoomViewModel allocateClassRoomViewModel) { var allocate = _mapper.Map <AllocateClassRoom>(allocateClassRoomViewModel); if (ModelState.IsValid) { bool isSaved = _allocateClassRoomManager.Add(allocate); if (isSaved) { ViewBag.Message = "Saved Successfully"; } } return(View()); }
public void Insert(AllocateClassRoomViewModel model) { if (model == null) { throw new ArgumentNullException("AllocateClassRoom"); } AllocateClassRoom classRoom = new AllocateClassRoom { DepartmentId = model.DepartmentId, RoomId = model.RoomId, CourseId = model.CourseId, Day = model.Day, From = model.From, To = model.To }; entities.Add(classRoom); _context.SaveChanges(); }
public ActionResult Create(AllocateClassRoomViewModel aAllocateClassRoomViewModel) { IEnumerable <Department> departments = aDepartmentManager.GetAllDepartment(); ViewBag.DeptList = new SelectList(departments, "Id", "Name"); IEnumerable <Course> courses = new List <Course>(); ViewBag.CourseList = new SelectList(courses, "Id", "Code"); IEnumerable <Room> rooms = aRoomManager.GetAllRooms(); ViewBag.RoomList = new SelectList(rooms, "Id", "RoomNumber"); IEnumerable <Day> days = aDayManager.GetAllDays(); ViewBag.DayList = new SelectList(days, "Id", "Name"); try { string msg = aAllocateManager.SaveAllocate(aAllocateClassRoomViewModel); if (msg == "Class room is Full in this Time Zone") { ViewBag.message = msg; return(View()); } ViewBag.message = msg; ModelState.Clear(); return(View(new AllocateClassRoomViewModel())); } catch { return(View()); } }
public void SoftDelete(AllocateClassRoomViewModel model) { throw new NotImplementedException(); }