예제 #1
0
        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");
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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();
            }

        }
예제 #4
0
 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();
 }
예제 #5
0
 public void GetCharityExam(int ceId)
 {
     ChairitiesExam = new ChairitiesExam();
     ChairitiesExam = db.ChairitiesExams.Find(ceId);
 }
예제 #6
0
 public bool AddCharityExam(ChairitiesExam ce)
 {
     try
     {
         using (var context = new TSMTEntities())
         {
             context.ChairitiesExams.Add(ce);
             context.SaveChanges();
             return true;
         }
     }
     catch (Exception ex)
     {
         return false;
     }
 }
예제 #7
0
        //[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);
        }