コード例 #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
ファイル: TrainClassBL.cs プロジェクト: Monikashree/DemoMvc
 public void DeleteTrainClass(TrainClassDetails trainClassDetails)   //Method to delete train class details
 {
     trainClassRepository.DeleteTrainClass(trainClassDetails);
 }
コード例 #9
0
ファイル: TrainClassBL.cs プロジェクト: Monikashree/DemoMvc
 public void EditTrainClass(TrainClassDetails trainClassDetails) // Method to edit and delete details based on ID
 {
     trainClassRepository.EditTrainClass(trainClassDetails);
 }
コード例 #10
0
ファイル: TrainClassBL.cs プロジェクト: Monikashree/DemoMvc
 public void AddTrainClass(TrainClassDetails trainClassDetails)
 {
     trainClassRepository.AddTrainClass(trainClassDetails);
 }