public ActionResult Index(string searchString, int id) { Complete rm = new Complete(); List<Complete> rmlist = new List<Complete>(); db.Rooms.ToList(); //foreach (RoomModel i in db.Rooms) //{ // if (i.DivingSpotID == id) // { // Complete rmcheck = new Complete(); // rmcheck.RM = i; // } //} //if (!String.IsNullOrEmpty(searchString)) //{ // string[] srcWords = searchString.Split(' '); // foreach (string word in srcWords) // { // rm = rm.Where(s => (s.RoomName.Contains(word) || s.RoomCategory.Contains(word))); // } //} //RM.AddRange(rm.Distinct()); //ViewBag.DSM = new List<RoomModel>(RM); return View(); }
public ActionResult Details(int id = 0) { Complete complete = new Complete(); complete.DSI = db.DivingSites.Find(id); List<string> images = new List<string>(); try { if (complete.DSI.SiteMultipleImage != null) { string[] imageUrl = complete.DSI.SiteMultipleImage.Split(','); foreach (string i in imageUrl) { images.Add(i); } } complete.DSI.images = images; } catch (Exception ex) { } if (complete.DSI == null) { return HttpNotFound(); } return View(complete.DSI); }
public ActionResult Create(Complete divingareamodel) { if (ModelState.IsValid) { db.DivingAreas.Add(divingareamodel.DAM); db.SaveChanges(); return RedirectToAction("Index"); } return View(divingareamodel); }
public ActionResult Create(Complete booking, int id) { if (booking.Book != null) { booking.Book.UserId = WebSecurity.GetUserId(User.Identity.Name); booking.Book.DivingSpotID = id; db.Bookings.Add(booking.Book); db.SaveChanges(); return RedirectToAction("Index", "Booking"); } return View(booking); }
// // GET: /DivingArea/Details/5 public ActionResult Details(int id = 0) { Complete dive = new Complete(); dive.DAM = db.DivingAreas.Find(id); List<DivingSpotModel> spotList = new List<DivingSpotModel>(); List<string> images = new List<string>(); try { if (dive.DAM.AreaMultipleImage != null) { string[] imageUrl = dive.DAM.AreaMultipleImage.Split(','); foreach (string i in imageUrl) { images.Add(i); } } dive.DAM.images = images; foreach (var item in db.DivingSpots.ToList()) { if (item.DivingAreaID == id) { spotList.Add(item); } } // dive.DSM = spotList; } catch (Exception ex) { } if (dive == null) { return HttpNotFound(); } return View(dive); }
// // GET: /Booking/Create public ActionResult Create(int id) { //Get current user ID to get the first name/last name int userID = WebSecurity.GetUserId(User.Identity.Name); Complete bm = new Complete(); using (UsersContext db2 = new UsersContext()) { //get user profile UserProfile user = db2.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == User.Identity.Name.ToLower()); if (user != null) { bm.UP = user; } } ViewBag.Message = id.ToString(); bm.DSM = db.DivingSpots.Find(id); return View(bm); }
// // GET: /Booking/Details/5 public ActionResult Details(int id = 0) { Complete booking = new Complete(); booking.Book = db.Bookings.Find(id); if (booking == null) { return HttpNotFound(); } return View(booking); }
// // GET: /Booking/ public ActionResult Index() { Complete bm = new Complete(); using (UsersContext db2 = new UsersContext()) { //get user profile UserProfile user = db2.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == User.Identity.Name.ToLower()); if (user != null) { bm.UP = user; } } if (bm.UP.UserName.Contains("admin")) { List<Complete> blist = new List<Complete>(); db.DivingSpots.ToList(); foreach (BookingModel i in db.Bookings) { Complete b = new Complete(); //Get booking b.Book = i; //Get Divingspot b.DSM = db.DivingSpots.Find(i.DivingSpotID); //Get user using (UsersContext db2 = new UsersContext()) { //get user profile b.UP = db2.UserProfiles.Find(i.UserId); } blist.Add(b); } return View(blist.ToList()); } else { //get current user id int userID = bm.UP.UserId; //Return all booking that has the same user ID List<Complete> blist = new List<Complete>(); db.DivingSpots.ToList(); foreach (BookingModel i in db.Bookings) { if (i.UserId == userID) { Complete b = new Complete(); //Get booking b.Book = i; //Get Divingspot b.DSM = db.DivingSpots.Find(i.DivingSpotID); //Get user using (UsersContext db2 = new UsersContext()) { //get user profile UserProfile user = db2.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == User.Identity.Name.ToLower()); if (user != null) { b.UP = user; } } blist.Add(b); } } return View(blist); } }