public ActionResult AddCharityExam(FormCollection f) { Account acc = (Account)Session["acc"]; Charity cha = acc.Charities.SingleOrDefault(r => r.AccountID == acc.AccountID); ChairitiesExam ce = new ChairitiesExam(); ce.ExamID = int.Parse(f["ExamId"]); ce.CharityID = cha.CharityID; //ce.CharityExamName = f["CharityExamName"]; ce.TotalSlotsLodges = 0; ce.AvailableSlotsLodges = 0; ce.TotalSlotsVehicles = 0; ce.AvailableSlotsVehicles = 0; db.ChairitiesExams.Add(ce); db.SaveChanges(); return RedirectToAction("ManageCharityExam"); }
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 void AssignCarstoCe(int eId, string carId, int cId) { string[] listStringId = carId.Split('-'); int[] listIntId = new int[listStringId.Length - 1]; for (int i = 0; i < listStringId.Length - 1; i++) { listIntId[i] = int.Parse(listStringId[i]); } ChairitiesExam cExam = new ChairitiesExam(); cExam = db.ChairitiesExams.FirstOrDefault(c => c.ExamID == eId && c.CharityID == cId); foreach (var i in listIntId) { Car car = db.Cars.SingleOrDefault(r => r.CarID == i); car.CharityExamID = cExam.CharityExamID; cExam.TotalSlotsVehicles += car.TotalSlots; cExam.AvailableSlotsVehicles += car.AvailableSlots; //lodge.TotalSlotsInUsed += room.TotalSlots; //lodge.AvailableSlots += room.AvailableSlots; db.SaveChanges(); } }
public void UpdateCharityExam(ChairitiesExam ceExam, int ceId) { var oldCe = db.ChairitiesExams.Find(ceId); oldCe.ExamID = ceExam.ExamID; oldCe.CharityID = ceExam.CharityID; oldCe.DistrictID = ceExam.DistrictID; oldCe.TotalSlotsLodges = ceExam.TotalSlotsLodges; oldCe.AvailableSlotsLodges = ceExam.TotalSlotsLodges; oldCe.TotalSlotsVehicles = ceExam.TotalSlotsVehicles; oldCe.AvailableSlotsVehicles = ceExam.TotalSlotsVehicles; db.SaveChanges(); }
public void GetCharityExam(int ceId) { ChairitiesExam = new ChairitiesExam(); ChairitiesExam = db.ChairitiesExams.Find(ceId); }
public bool AddCharityExam(ChairitiesExam ce) { try { using (var context = new TSMTEntities()) { context.ChairitiesExams.Add(ce); context.SaveChanges(); return true; } } catch (Exception ex) { return false; } }
//[CheckAuth("~/Account/Login",4, "/" )] public ActionResult ManageLodge() { Account acc = (Account)Session["acc"]; var lodges = db.Lodges.Where(r => r.Sponsor.AccountID == acc.AccountID).ToList(); foreach (var i in lodges) { if (i.ChairitiesExam == null) { var chairitiesExam = new ChairitiesExam(); chairitiesExam.Examination = new Examination(); i.ChairitiesExam = chairitiesExam; } } ViewData["LodgesNotSponsored"] = db.Lodges.Where(r => r.Sponsor.AccountID == acc.AccountID && r.CharityExamID == null); ViewData["LodgesSponsored"] = db.Lodges.Where(r => r.Sponsor.AccountID == acc.AccountID && r.CharityExamID != null); return View(lodges); }