public bool BookThisClassForMyPet( PetClass target,Pet pet, Customer owner) { pet.HasClass = true; target.Pets.Add(pet); target.BookedCustomers.Add(owner); return UpdatePetClass(target); }
public ActionResult Create(Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CityId = new SelectList(db.Cities, "CityId", "Name", customer.CityId); return View(customer); }
/// <summary> /// Subscribe all pets of gienCustomer to a given class,before calling this method, make sure to include the pets to Customer. /// </summary> /// <param name="classId"></param> /// <param name="owner"></param> /// <returns>true on success, false if thers no space for all incoming pets</returns> public bool BookAllMyPetsToThisClass(PetClass target, Customer owner) { if(HasEnoughCapacity(target, owner.Pets.Count)) { foreach (Pet p in owner.Pets) { target.Pets.Add(p); } target.BookedCustomers.Add(owner); return UpdatePetClass(target); } return false; }
public ActionResult Register(Customer cModel) { var cityId = Request.Form["citylist"]; ViewBag.citylist = getCities(); ViewBag.Message = "Thank you for registering. "; //check whether the email is already exist or not var customer = from p in db.Customers select p; customer = customer.Where(s => s.Email.Equals(cModel.Email)); if (customer.Count() != 0) { ViewBag.Message = null; ViewBag.ErrorMessage = "Your email address is already exists. Please choose another email address."; return View(); } else { cModel.JoinedDate = DateTime.Now; cModel.LastUpdate = DateTime.Now; cModel.CityId = Convert.ToInt16(cityId); db.Customers.Add(cModel); db.SaveChanges(); Session["currentUser"] = cModel; return View("Dashboard"); } }
public ActionResult Login(Customer cModel) { //check whether the customer is in the database and using the correct email & password var customer = from p in db.Customers select p; customer = customer.Where(s => s.Email.Equals(cModel.Email)); customer = customer.Where(s => s.Password.Equals(cModel.Password)); //validating the customer email and password if (customer.Count() == 0 || cModel.Email == "" || cModel.Password == "") { ViewBag.Message = "Wrong email or password"; return View("Login"); } else { //foreach (var c in customer) //{ Session["currentUser"] = customer.First(); //} return View("Dashboard"); } }
public ActionResult EditDetails(Customer cModel) { //cModel.Description = var currentUser = (Customer)Session["currentUser"]; //var cityId = Request.Form["citylist"]; ViewBag.CityId = new SelectList(db.Cities, "CityId", "Name", cModel.CityId); cModel.LastUpdate = DateTime.Now; cModel.Email = currentUser.Email; cModel.Password = currentUser.Password; cModel.JoinedDate = currentUser.JoinedDate; //cModel.LastUpdate = DateTime.Now; //cModel.CityId = Convert.ToInt16(cityId); if (ModelState.IsValid) { db.Entry(cModel).State = EntityState.Modified; db.SaveChanges(); } ViewBag.Message = "Your details has been updated."; Session["currentUser"] = cModel; return View(); }
public ActionResult Edit(Customer customer) { if (ModelState.IsValid) { db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CityId = new SelectList(db.Cities, "CityId", "Name", customer.CityId); return View(customer); }
public bool BookThisClassForMyPet(int classId, Pet pet, Customer owner) { PetClass target = GetPetClassById(classId); return BookThisClassForMyPet(target, pet, owner); }