public ActionResult Modify_AddonCategory(AddonCatViewModel modifiedaddoncat) { var success = false; var message = ""; if (!ModelState.IsValid) { return(PartialView(modifiedaddoncat)); } try { var addoncat = new AddonCategory() { addoncatId = (int)modifiedaddoncat.addoncatId, addoncatdesc = modifiedaddoncat.addoncatdetails }; dbEntities.AddonCategories.Attach(addoncat); dbEntities.Entry(addoncat).State = EntityState.Modified; dbEntities.SaveChanges(); success = true; } catch (Exception e) { message = e.Message.ToString(); success = false; } return(Json(new { success = success }, JsonRequestBehavior.AllowGet)); }
public ActionResult ModifyReservation(ReservationViewModel modifyreserrvation) { if (!ModelState.IsValid) { return(View(modifyreserrvation)); } bool success = false; try { var reservation = new Reservation() { resId = Convert.ToInt32(modifyreserrvation.reservationId), c_Id = modifyreserrvation.customerId, resDate = modifyreserrvation.reserveDate, noofPax = Convert.ToInt32(modifyreserrvation.noofperson), occasion = modifyreserrvation.occasion, eventVenue = modifyreserrvation.eventVenue, reserveStat = false }; dbEntities.Reservations.Attach(reservation); dbEntities.Entry(reservation).State = EntityState.Modified; dbEntities.SaveChanges(); success = true; } catch (Exception e) { Console.WriteLine(e); throw; } return(Json(new { success = success }, JsonRequestBehavior.AllowGet)); //return View("Index"); }
public ActionResult RemoveCourse(int courseId) { string deletedcourse = null; bool success = false; try { var course = _dbcontext.CourseCategories.Find(courseId); if (course != null) { //check if course has no booking menus bool has_existing_book = cv.isCoursehasBooking(courseId); if (has_existing_book == false) { //if course has menus but no bookings var has_menus = cv.isCourseHasMenus(courseId).ToList(); if (has_menus.Any()) { foreach (var item in has_menus) { var menu = _dbcontext.Menus.Find(item.menu_Id); _dbcontext.Menus.Remove(menu); _dbcontext.Entry(menu).State = EntityState.Deleted; } } _dbcontext.CourseCategories.Remove(course); _dbcontext.SaveChanges(); deletedcourse = course.Course; success = true; } else { deletedcourse = course.Course; return(Json(new { deletedcourse = deletedcourse, success = false }, JsonRequestBehavior.AllowGet)); } } } catch (Exception e) { // throw new HttpException(404, "Page Not Found"); Console.WriteLine(e); throw; } return(Json(new { deletedcourse = deletedcourse, success = success }, JsonRequestBehavior.AllowGet)); }
public ActionResult ModifyDiscount(DiscountCodeDetailsViewModel modifieddiscountviewmodel) { bool success = false; if (!ModelState.IsValid) { return(PartialView("_modifyDiscountPartialView", modifieddiscountviewmodel)); } try { var discount = new Discount() { disc_Id = Convert.ToInt32(modifieddiscountviewmodel.disc_Id), discCode = modifieddiscountviewmodel.discCode, disctype = modifieddiscountviewmodel.disctype, discount1 = modifieddiscountviewmodel.discount_amt, discStartdate = modifieddiscountviewmodel.discStartdate, discEnddate = modifieddiscountviewmodel.discEnddate }; _dbEntities.Discounts.Attach(discount); _dbEntities.Entry(discount).State = EntityState.Modified; _dbEntities.SaveChanges(); success = true; } catch (Exception e) { Console.WriteLine(e); throw; } return(Json(new { success = success }, JsonRequestBehavior.AllowGet)); }
public ActionResult ModifyPackageLocation(PackageAreaLocationViewModel packageAreaViewModel) { if (!ModelState.IsValid) { return(PartialView("_modifypackagelocationCoverage", packageAreaViewModel)); } var packageCoverage = new PackageAreaCoverage() { p_id = packageAreaViewModel.p_id, aID = packageAreaViewModel.aID, p_areaNo = (int)packageAreaViewModel.p_areaNo, is_extended = packageAreaViewModel.is_extended, ext_amount = packageAreaViewModel.ext_amount }; _dbcontext.PackageAreaCoverages.Attach(packageCoverage); _dbcontext.Entry(packageCoverage).State = EntityState.Modified; _dbcontext.SaveChanges(); return(Json(new { success = true, packageId = packageAreaViewModel.p_id }, JsonRequestBehavior.AllowGet)); }
public ActionResult ModifyArea(AreaDetailsViewModel modify_Area) { if (!ModelState.IsValid) { return(PartialView("_modifyAreaPartialView", modify_Area)); } var recordexist = _dbcontext.Areas.Any(x => x.AreaDetails.ToLower().Contains(modify_Area.areaDetails.ToLower())); if (recordexist) { return(Json(new { success = false, message = modify_Area.areaDetails + "is already in the list" }, JsonRequestBehavior.AllowGet)); } else { try { var _area = modify_Area.areaDetails.ToUpper(); Area modifyArea = new Area() { aID = Convert.ToInt32(modify_Area.areaId), AreaDetails = _area }; _dbcontext.Areas.Attach(modifyArea); _dbcontext.Entry(modifyArea).State = EntityState.Modified; _dbcontext.SaveChanges(); } catch (Exception e) { Console.WriteLine(e); throw; } } return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult ModifyAddonDetails(AddonsViewModel modifyaddonsdetails) { var success = false; var message = ""; if (!ModelState.IsValid) { return(PartialView("ModifyAddonDetails", modifyaddonsdetails)); } try { AddonDetail addondetail = new AddonDetail() { addonId = (int)modifyaddonsdetails.addonId, addoncatId = modifyaddonsdetails.addoncatId, deptId = modifyaddonsdetails.deptId, addondescription = modifyaddonsdetails.AddonsDescription, unit = modifyaddonsdetails.Unit, amount = modifyaddonsdetails.AddonAmount }; dbEntities.AddonDetails.Attach(addondetail); dbEntities.Entry(addondetail).State = EntityState.Modified; dbEntities.SaveChanges(); success = true; } catch (Exception e) { message = e.Message.ToString(); success = false; } return(Json(new { success = success }, JsonRequestBehavior.AllowGet)); }
public void SetCancelBooking(int transId) { var dbcontext = new PegasusEntities(); var booking = dbcontext.Bookings.FirstOrDefault(x => x.trn_Id == transId); try { if (booking != null) { booking.is_cancelled = true; dbcontext.Bookings.Attach(booking); dbcontext.Entry(booking).Property(x => x.is_cancelled).IsModified = true; dbcontext.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e); throw; } }