//public ActionResult ViewRoutes() //{ // return View(); //} public ActionResult ViewRountes(int id) { //SchedulesVolunteer schedulesVolunteer = db.SchedulesVolunteers.FirstOrDefault(s => s.ScheduleVolunteerID == scheduleId); //if (schedulesVolunteer != null) //{ // ViewData["StarEndPoint"] = schedulesVolunteer.StartEndPoint; // ViewData["WayPoint"] = schedulesVolunteer.WayPoint; // ViewData["ScheduleId"] = scheduleId; // ViewData["WayPointEdit"] = ""; //} ParticipantVolunteer schedulesVolunteer = db.ParticipantVolunteers.FirstOrDefault(s => s.ParticipantVolunteerID == id); if (schedulesVolunteer != null) { var endPoint = schedulesVolunteer.ExaminationsPaper.Venue.Address; var startPoint = schedulesVolunteer.ExaminationsPaper.Lodge.Address; ViewData["StarEndPoint"] = startPoint + ";" + endPoint; ViewData["WayPoint"] = schedulesVolunteer.WayPoints; ViewData["ScheduleId"] = id; ViewData["WayPointEdit"] = ""; Lodge lodge = new Lodge(); lodge = db.Lodges.FirstOrDefault(l => l.LodgeID == schedulesVolunteer.ExaminationsPaper.LodgeRegisteredID); ViewData["StartPlace"] = lodge.Address; ViewData["EndPlace"] = schedulesVolunteer.ExaminationsPaper.Venue.Address; } return View("DisplayRouteVolunteer"); }
public ActionResult AddLodge(FormCollection f) { Lodge lodge = new Lodge(); //if (f["CharityExamID"] != null) //{ // lodge.CharityExamID = int.Parse(f["CharityExamID"]); //} lodge.Longitude = f["Longitude"]; lodge.Latitude = f["Latitude"]; lodge.Address = f["Address"]; lodge.CharityID = int.Parse(f["ceId"]); lodge.TotalSlots = 0; lodge.AvailableSlots = 0; lodge.TotalSlotsInUsed = 0; lodge.IsApproved = true; //if (lodge.CharityExamID != null) //{ // ChairitiesExam ce = db.ChairitiesExams.SingleOrDefault(r => r.CharityExamID == lodge.CharityExamID); // ce.TotalSlotsLodges += lodge.TotalSlots; // ce.AvailableSlotsLodges += lodge.AvailableSlots; // db.SaveChanges(); //} db.Lodges.Add(lodge); db.SaveChanges(); return RedirectToAction("DetailsLodge", new { id = lodge.LodgeID }); }
public void ChooseRoomsForCe(int eId, string roomId, int lodgeId, int cId) { string[] listStringId = roomId.Split('-'); int[] listIntId = new int[listStringId.Length - 1]; for (int i = 0; i < listStringId.Length - 1; i++) { listIntId[i] = int.Parse(listStringId[i]); } Lodge lodgeNew = new Lodge(); Lodge lodge = db.Lodges.SingleOrDefault(r => r.LodgeID == lodgeId); lodgeNew = lodge; ChairitiesExam cExam = new ChairitiesExam(); cExam = db.ChairitiesExams.FirstOrDefault(c => c.CharityExamID == eId && c.CharityID == cId); lodgeNew.CharityExamID = cExam.CharityExamID; lodgeNew.CharityID = cId; lodgeNew.TotalSlotsInUsed = 0; lodgeNew.AvailableSlots = 0; db.Lodges.Add(lodgeNew); db.SaveChanges(); Lodge lodgeNewest = db.Lodges.FirstOrDefault(l => l.Address == lodgeNew.Address && l.CharityExamID == cExam.CharityExamID); foreach (var i in listIntId) { Room roomNew = new Room(); Room room = db.Rooms.SingleOrDefault(r => r.RoomID == i); roomNew = room; roomNew.LodgeID = lodgeNewest.LodgeID; roomNew.CharityExamID = cExam.CharityExamID; cExam.TotalSlotsLodges += room.TotalSlots; cExam.AvailableSlotsLodges += room.AvailableSlots; lodgeNewest.TotalSlotsInUsed += room.TotalSlots; lodgeNewest.AvailableSlots += room.AvailableSlots; db.Rooms.Add(roomNew); db.SaveChanges(); } }
public ActionResult ViewVolunteer(int id) // pvId { ParticipantVolunteer pv = db.ParticipantVolunteers.FirstOrDefault(s => s.ParticipantVolunteerID == id); if (pv != null && pv.ExamPaperID != null) { var endPoint = pv.ExaminationsPaper.Venue.Address; var startPoint = pv.ExaminationsPaper.Lodge.Address; ViewData["StarEndPoint"] = startPoint + ";" + endPoint; ViewData["WayPoint"] = pv.WayPoints; ViewData["ScheduleId"] = id; ViewData["WayPointEdit"] = ""; Lodge lodge = new Lodge(); lodge = db.Lodges.FirstOrDefault(l => l.LodgeID == pv.ExaminationsPaper.LodgeRegisteredID); ViewData["StartPlace"] = lodge.Address; ViewData["EndPlace"] = pv.ExaminationsPaper.Venue.Address; } return View(pv); }
public ActionResult ViewCar(int id) // carId { Car car = db.Cars.SingleOrDefault(r => r.CarID == id); if (car.ExaminationsPapers.Count > 0) { Lodge lodge = new Lodge(); ExaminationsPaper examinationsPaper = new ExaminationsPaper(); examinationsPaper = car.ExaminationsPapers.FirstOrDefault(); lodge = db.Lodges.FirstOrDefault(l => l.LodgeID == examinationsPaper.LodgeRegisteredID); List<string> address = new List<string>(); address.Add(lodge.Address); var venues = new List<Venue>(); List<int> venueIDs = new List<int>(); venueIDs = car.ExaminationsPapers.Select(r => r.VenueID).Distinct().ToList(); foreach (int venueID in venueIDs) address.Add(db.Venues.SingleOrDefault(r => r.VenueID == venueID).Address); ViewData["Place"] = address; } return View(car); }
public ActionResult DisplayRoute(int id) // carId { Car car = db.Cars.SingleOrDefault(r => r.CarID == id); Lodge lodge = new Lodge(); ExaminationsPaper examinationsPaper = new ExaminationsPaper(); examinationsPaper = car.ExaminationsPapers.FirstOrDefault(); lodge = db.Lodges.FirstOrDefault(l => l.LodgeID == examinationsPaper.LodgeRegisteredID); List<string> address = new List<string>(); address.Add(lodge.Address); var venues = new List<Venue>(); List<int> venueIDs = new List<int>(); // ds dia diem thi cua cac thi sinh thuoc xe nay. venueIDs = car.ExaminationsPapers.Select(r => r.VenueID).Distinct().ToList(); foreach (int venueID in venueIDs) { address.Add(db.Venues.SingleOrDefault(r => r.VenueID == venueID).Address); } //var listExamPaper = new List<Owner>(); //listExamPaper = db.ExaminationsPapers.Where(e => e.CarID == carId).ToList(); //var listVenue = new List<Venue>(); //foreach (var ex in listExamPaper) //{ // listVenue.Add(ex.Venue); //} //listVenue = listVenue.Distinct().ToList(); //var ep = new Owner(); //var lodge = new Lodge(); //var examPaper = listExamPaper.FirstOrDefault(); //if (examPaper != null) joinIn = examPaper.JoinsIns.FirstOrDefault(); //if (joinIn != null) lodge = joinIn.Room.Lodge; //var address = new List<string>(); //address.Add(lodge.Address); //foreach (var venue in listVenue) //{ // address.Add(venue.Address); //} //address = new List<string>(); //address.Add("03 hoa binh, quan 11"); //address.Add("100 quang trung, quan 12"); //address.Add("12 nguyen van bao, quan go vap"); //address.Add("cong truong me linh"); ViewData["Place"] = address; //ViewData["Place"] = // "[{\"index\": 0, \"address\": \"01 le duan, quan 1\"}, {\"index\": 1, \"address\": \"01 lac long quan, quan tan binh\"}, {\"index\": 2, \"address\": \"01 tran quang khai, quan 1\"}, {\"index\": 3, \"address\": \"59 nguyen hong dao, quan tan binh\"}]"; return View(); }
public ActionResult AddLodge(FormCollection f) { Account acc = (Account)Session["acc"]; Sponsor sp = db.Sponsors.SingleOrDefault(r => r.AccountID == acc.AccountID); Lodge lodge = new Lodge(); lodge.SponsorID = sp.SponsorID; lodge.Longitude = f["Longitude"]; lodge.Latitude = f["Latitude"]; lodge.Address = f["Address"]; lodge.TotalSlotsInUsed = 0; lodge.TotalSlots = 0; lodge.AvailableSlots = 0; db.Lodges.Add(lodge); db.SaveChanges(); return RedirectToAction("ManageRoom", new { id = lodge.LodgeID }); }
public void EditLodge(int ceId, string roomId, int lodgeId, int cId) { string[] listStringId = roomId.Split('-'); int[] listIntId = new int[listStringId.Length - 1]; for (int i = 0; i < listStringId.Length - 1; i++) { listIntId[i] = int.Parse(listStringId[i]); } Lodge lodgeNew = new Lodge(); Lodge lodge = db.Lodges.SingleOrDefault(r => r.LodgeID == lodgeId); lodgeNew = lodge; lodgeNew.AvailableSlots = 0; lodgeNew.TotalSlotsInUsed = 0; //List<Room> listRoom = new List<Room>(); //listRoom = lodge.Rooms.ToList(); //foreach (var room in listRoom) //{ // room.CharityExamID = null; // db.SaveChanges(); //} lodgeNew.CharityExamID = ceId; lodgeNew.CharityID = cId; db.Lodges.Add(lodgeNew); db.SaveChanges(); Lodge lodgeNewest = db.Lodges.FirstOrDefault(l => l.Address == lodgeNew.Address && l.CharityExamID == lodgeNew.CharityExamID); foreach (var i in listIntId) { Room roomNew = new Room(); Room room = db.Rooms.SingleOrDefault(r => r.RoomID == i); roomNew = room; roomNew.LodgeID = lodgeNewest.LodgeID; roomNew.CharityExamID = lodgeNewest.CharityExamID; lodgeNewest.TotalSlotsInUsed += room.TotalSlots; lodgeNewest.AvailableSlots += room.TotalSlots; db.Rooms.Add(roomNew); db.SaveChanges(); } }