예제 #1
0
        public ActionResult DeleteTrainClass(int id)
        {                                                                           //Delete Train Detail
            TrainClassDetails trainClassDetails = trainClassBL.GetClass(id);

            trainClassBL.DeleteTrainClass(trainClassDetails);
            return(RedirectToAction("DisplayTrainCategories", trainClassDetails.TrainId));
        }
예제 #2
0
        public ActionResult EditTrainClass(int id)
        {
            TrainClassDetails          trainClassDetails          = trainClassBL.GetClass(id); //Editing Train Class Detail
            TrainClassDetailsViewModel trainClassDetailsViewModel = AutoMapper.Mapper.Map <TrainClassDetails, TrainClassDetailsViewModel>(trainClassDetails);

            return(View(trainClassDetailsViewModel));
        }
예제 #3
0
 public void DeleteTrainClass(TrainClassDetails trainClassDetails)       //Method to delete train class using stored procedure
 {
     using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext())
     {
         SqlParameter ClassId = new SqlParameter("@TrainClassDetailsId", trainClassDetails.TrainClassDetailsId);
         int          result  = dbContext.Database.ExecuteSqlCommand("sp_DeleteTrainClassDetails @TrainClassDetailsId", ClassId);
     }
 }
예제 #4
0
 public void EditTrainClass(TrainClassDetails trainClassDetails)     //method to update train class
 {
     using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext())
     {
         dbContext.Entry(trainClassDetails).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
예제 #5
0
 public void AddTrainClass(TrainClassDetails trainClassDetails)      //Method to add train class
 {
     using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext())
     {
         dbContext.TrainClassDetails.Add(trainClassDetails);
         dbContext.SaveChanges();
     }
 }
예제 #6
0
 public ActionResult EditTrainClass(TrainClassDetailsViewModel trainClassdetailsViewModel)
 {
     if (ModelState.IsValid)
     {
         TrainClassDetails trainClassDetails = AutoMapper.Mapper.Map <TrainClassDetailsViewModel, TrainClassDetails>(trainClassdetailsViewModel);
         trainClassBL.EditTrainClass(trainClassDetails);
         TempData["TrainId"] = trainClassDetails.TrainId;
         return(RedirectToAction("DisplayTrainCategories"));
     }
     return(View());
 }
예제 #7
0
        [ValidateAntiForgeryToken]                                          //Antiforgery key token to prevent CSRF attack
        public ActionResult AddTrainClass(TrainClassDetailsViewModel trainClassDetailsViewModel)
        {
            List <TrainClass>     trainClassList = trainClassBL.GetTrainClassList();
            List <SelectListItem> classList      = new List <SelectListItem>();

            foreach (TrainClass trainClass in trainClassList)       //Using view bag to get train class
            {
                classList.Add(new SelectListItem {
                    Text = @trainClass.ClassName, Value = @trainClass.ClassId.ToString()
                });
            }
            ViewBag.classes = classList;
            if (ModelState.IsValid)
            {
                TrainClassDetails trainClassDetails = AutoMapper.Mapper.Map <TrainClassDetailsViewModel, TrainClassDetails>(trainClassDetailsViewModel);
                trainClassBL.AddTrainClass(trainClassDetails);
                TempData["TrainId"] = trainClassDetails.TrainId;
                return(RedirectToAction("DisplayTrainCategories"));
            }
            return(View());
        }
예제 #8
0
 public void DeleteTrainClass(TrainClassDetails trainClassDetails)   //Method to delete train class details
 {
     trainClassRepository.DeleteTrainClass(trainClassDetails);
 }
예제 #9
0
 public void EditTrainClass(TrainClassDetails trainClassDetails) // Method to edit and delete details based on ID
 {
     trainClassRepository.EditTrainClass(trainClassDetails);
 }
예제 #10
0
 public void AddTrainClass(TrainClassDetails trainClassDetails)
 {
     trainClassRepository.AddTrainClass(trainClassDetails);
 }