public ActionResult Create([Bind(Include = "Username,Password")] Admin admin) { if (ModelState.IsValid) { try { admin.Password = Encrypt.MD5_Encode(admin.Password); db.Admins.Add(admin); db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return(RedirectToAction("Index")); } return(View(admin)); }
public ActionResult Edit([Bind(Include = "Customer_Id,Customer_Password,Customer_LastName,Customer_FirstName,Customer_Bithday,Customer_Gender,Customer_Phone,Customer_Address,Customer_Email,Customer_Possport")] Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "Location_Id,Location_Name,Location_Location")] Location location) { if (ModelState.IsValid) { db.Locations.Add(location); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(location)); }
public ActionResult Create([Bind(Include = "FeedbackId,SenderName,SenderMail,FeedBackTitle,FeedBackContent,State,Create_on")] Feedback feedback) { if (ModelState.IsValid) { db.Feedbacks.Add(feedback); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(feedback)); }
public ActionResult Create([Bind(Include = "PaymentId,PaymentName")] PaymentMethod paymentMethod) { if (ModelState.IsValid) { db.PaymentMethods.Add(paymentMethod); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(paymentMethod)); }
public ActionResult Create([Bind(Include = "AboutId,AboutName,AboutBirth,AboutGender,AboutLike,AboutImg")] About about) { if (ModelState.IsValid) { db.Abouts.Add(about); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(about)); }
public ActionResult Create([Bind(Include = "Room_Id,Room_Type,Room_Name,Room_Start,Room_Stop,Room_Cost,Hotel_Id")] Room room) { if (ModelState.IsValid) { db.Rooms.Add(room); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Hotel_Id = new SelectList(db.Hotels, "Hotel_Id", "Hotel_Name", room.Hotel_Id); return(View(room)); }
public ActionResult Create([Bind(Include = "Food_Code,Food_Name,Food_Cost,Food_Specific,Restaurant_Code")] Food food) { if (ModelState.IsValid) { db.Foods.Add(food); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Restaurant_Code = new SelectList(db.Restaurants, "Restaurant_Code", "Restaurant_Name", food.Restaurant_Code); return(View(food)); }
public ActionResult Create([Bind(Include = "Hotel_Id,Hotel_Name,Hotel_Address,Hotel_Status,Hotel_Details,TouristSpot_Id,Hotel_Create")] Hotel hotel) { if (ModelState.IsValid) { db.Hotels.Add(hotel); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TouristSpot_Id = new SelectList(db.TouristSpots, "TouristSpot_Id", "TouristSpot_Name", hotel.TouristSpot_Id); return(View(hotel)); }
public ActionResult Create([Bind(Include = "Restaurant_Code,Restaurant_Name,Restaurant_Address,Restaurant_Status,Restaurant_Description,TouristSpot_Id,Restaurant_Create")] Restaurant restaurant) { if (ModelState.IsValid) { db.Restaurants.Add(restaurant); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TouristSpot_Id = new SelectList(db.TouristSpots, "TouristSpot_Id", "TouristSpot_Name", restaurant.TouristSpot_Id); return(View(restaurant)); }
public ActionResult Create([Bind(Include = "Vehicle_Id,Vehicle_Name,Vehicle_Price,Vehicle_Weight,Vehicle_Img,Transportation_Id")] Vehicle vehicle) { if (ModelState.IsValid) { db.Vehicles.Add(vehicle); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Transportation_Id = new SelectList(db.Transportations, "Transportation_Id", "Transportation_Name", vehicle.Transportation_Id); return(View(vehicle)); }
public ActionResult Create([Bind(Include = "Transportation_Id,Transportation_Name,Transportation_Details,Transportation_Img,TouristSpot_Id,Transportation_Create")] Transportation transportation) { if (ModelState.IsValid) { db.Transportations.Add(transportation); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TouristSpot_Id = new SelectList(db.TouristSpots, "TouristSpot_Id", "TouristSpot_Name", transportation.TouristSpot_Id); return(View(transportation)); }
public ActionResult Register([Bind(Include = "Customer_Id,Customer_Password,Customer_LastName,Customer_FirstName,Customer_Bithday,Customer_Gender,Customer_Phone,Customer_Address,Customer_Email,Customer_Possport")] Customer customer) { if (ModelState.IsValid) { try { customer.Customer_Password = Encrypt.MD5_Encode(customer.Customer_Password); db.Customers.Add(customer); db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return(RedirectToAction("Home", "Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "TouristSpot_Id,TouristSpot_Name,TouristSpot_Limit,TouristSpot_Price,TouristSpot_Specific,TouristSpot_Status,Location_Id,TouristSpot_Create")] TouristSpot touristSpot) { if (ModelState.IsValid) { db.TouristSpots.Add(touristSpot); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Location_Id = new SelectList(db.Locations, "Location_Id", "Location_Name", touristSpot.Location_Id); return(View(touristSpot)); }
public ActionResult Profile(Employee data, HttpPostedFileBase avatar) { int id = int.Parse(User.Identity.Name); var emp = db.Employees.Find(id); emp.EmployeeName = data.EmployeeName; emp.Phone = data.Phone; emp.Address = data.Address; emp.Email = data.Email; try { if (avatar != null) { string dir = Server.MapPath("\\") + "\\Content\\avatar\\" + id + "\\"; if (System.IO.File.Exists(dir + emp.Avatar)) { System.IO.File.Delete(dir + emp.Avatar); } string filename = avatar.FileName.Split('\\').Last(); if (System.IO.Directory.Exists(dir) == false) { System.IO.Directory.CreateDirectory(dir + data.Id); } avatar.SaveAs(dir + filename); emp.Avatar = filename; } db.SaveChanges(); ViewBag.Message = "Ok"; } catch (Exception ex) { ViewBag.Message = ex.Message; } return(View(emp)); }