Ejemplo n.º 1
0
        public ActionResult AddDepartment(DepartmentViewModel departmentViewModel)
        {
            IEnumerable <Department> departments = departmentBL.GetDepartmentList();
            List <SelectListItem>    deptList    = new List <SelectListItem>();

            foreach (Department department in departments)
            {
                deptList.Add(new SelectListItem {
                    Text = @department.DeptName, Value = @department.DeptId.ToString()
                });
            }
            ViewBag.Dept = deptList;
            if (ModelState.IsValid)
            {
                CollegeDepartment collegeDepartment = AutoMapper.Mapper.Map <DepartmentViewModel, CollegeDepartment>(departmentViewModel);
                if (departmentBL.AddDepartmentByCollege(collegeDepartment))
                {
                    TempData["CollegeCode"] = collegeDepartment.CollegeCode;
                    TempData["Message"]     = Message.Added;
                    return(RedirectToAction("DisplayDepartmentByCollege"));
                }
                ViewData["Message"] = Message.AlreadyAdded;
            }
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult DeleteDepartment(int id)
        {
            CollegeDepartment   collegeDepartment   = departmentBL.GetDepartment(id);
            DepartmentViewModel departmentViewModel = AutoMapper.Mapper.Map <CollegeDepartment, DepartmentViewModel>(collegeDepartment);

            return(View(departmentViewModel));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteDepartment(DepartmentViewModel departmentViewModel)
        {
            CollegeDepartment collegeDepartment = Mapper.Map <DepartmentViewModel, CollegeDepartment>(departmentViewModel);

            TempData["CollegeCode"] = collegeDepartment.CollegeCode;
            departmentBL.DeleteDepartment(collegeDepartment.ID);
            TempData["Message"] = Message.Deleted;
            return(RedirectToAction("DisplayDepartmentByCollege"));
        }
Ejemplo n.º 4
0
 //
 //Summary:
 // This Method Check the Department is Exists or not and the Add to the Databae.
 public bool AddDepartmentByCollege(CollegeDepartment collegeDepartment)
 {
     if (departmentRepository.CheckExistsDepartment(collegeDepartment.DeptId, collegeDepartment.CollegeCode) == null)
     {
         departmentRepository.AddDepartmentByCollege(collegeDepartment);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 public ActionResult EditDepartment(DepartmentViewModel departmentViewModel)
 {
     if (ModelState.IsValid)
     {
         CollegeDepartment collegeDepartment = Mapper.Map <DepartmentViewModel, CollegeDepartment>(departmentViewModel);
         departmentBL.EditDepartment(collegeDepartment);
         TempData["CollegeCode"] = collegeDepartment.CollegeCode;
         return(RedirectToAction("DisplayDepartmentByCollege"));
     }
     return(View());
 }
Ejemplo n.º 6
0
 //
 //Summary:
 //  This method is to Add Department to database
 public void AddDepartmentByCollege(CollegeDepartment collegeDepartment)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         //SqlParameter DeptId = new SqlParameter("@DeptId", collegeDepartment.DeptId);
         //SqlParameter collegeCode = new SqlParameter("@CollegeCode", collegeDepartment.CollegeCode);
         //SqlParameter AvailableSeats = new SqlParameter("@AvailableSeats", collegeDepartment.AvailableSeats);
         //collegeDBContext.Database.ExecuteSqlCommand("@DeptId, @CollegeCode, @AvailableSeats", DeptId, collegeCode, AvailableSeats);
         collegeDBContext.CollegeDepartments.Add(collegeDepartment);
         collegeDBContext.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 //
 //Summary:
 //  This method is to Update Department to database
 public void EditDepartment(CollegeDepartment collegeDepartment)
 {
     using (CollegeDBContext collegeDBContext = new CollegeDBContext())
     {
         //SqlParameter Id = new SqlParameter("@ID", collegeDepartment.ID);
         //SqlParameter DeptId = new SqlParameter("@DeptId", collegeDepartment.DeptId);
         //SqlParameter collegeCode = new SqlParameter("@CollegeCode", collegeDepartment.CollegeCode);
         //SqlParameter AvailableSeats = new SqlParameter("@AvailableSeats", collegeDepartment.AvailableSeats);
         //collegeDBContext.Database.ExecuteSqlCommand("CollegeDepartment_Update @ID, @DeptId, @CollegeCode, @AvailableSeats", Id, DeptId, collegeCode, AvailableSeats);
         collegeDBContext.Entry(collegeDepartment).State = EntityState.Modified;
         collegeDBContext.SaveChanges();
     }
 }
Ejemplo n.º 8
0
        public bool AddApplication(UserApplication application)
        {
            DepartmentRepository departmentRepository = new DepartmentRepository();
            CollegeDepartment    collegeDepartment    = departmentRepository.CheckExistsDepartment(application.DeptID, application.CollegeCode);

            if (collegeDepartment.AvailableSeats > 0)
            {
                collegeDepartment.AvailableSeats = collegeDepartment.AvailableSeats - 1;
                departmentRepository.EditDepartment(collegeDepartment);
                applicationRepository.AddApplication(application);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
 public void EditDepartment(CollegeDepartment collegeDepartment)
 {
     departmentRepository.EditDepartment(collegeDepartment);
 }