public ActionResult DeleteTrainClass(int id) { //Delete Train Detail TrainClassDetails trainClassDetails = trainClassBL.GetClass(id); trainClassBL.DeleteTrainClass(trainClassDetails); return(RedirectToAction("DisplayTrainCategories", trainClassDetails.TrainId)); }
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)); }
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); } }
public void EditTrainClass(TrainClassDetails trainClassDetails) //method to update train class { using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext()) { dbContext.Entry(trainClassDetails).State = EntityState.Modified; dbContext.SaveChanges(); } }
public void AddTrainClass(TrainClassDetails trainClassDetails) //Method to add train class { using (TrainTicketBookingDbContext dbContext = new TrainTicketBookingDbContext()) { dbContext.TrainClassDetails.Add(trainClassDetails); dbContext.SaveChanges(); } }
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()); }
[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()); }
public void DeleteTrainClass(TrainClassDetails trainClassDetails) //Method to delete train class details { trainClassRepository.DeleteTrainClass(trainClassDetails); }
public void EditTrainClass(TrainClassDetails trainClassDetails) // Method to edit and delete details based on ID { trainClassRepository.EditTrainClass(trainClassDetails); }
public void AddTrainClass(TrainClassDetails trainClassDetails) { trainClassRepository.AddTrainClass(trainClassDetails); }