public ActionResult Create(Service service) { if (ModelState.IsValid) { db.Services.Add(service); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ProviderId = new SelectList(db.Customers, "CustomerId", "Username", service.ProviderId); return View(service); }
public ActionResult SearchPetServiceResult(Service cService, decimal fromPrice = -12, decimal toPrice = -12) { // get list of all valid services var theService = (from customer in db.Customers join service in db.Services on customer.CustomerId equals service.ProviderId where service.ServiceName.Equals(cService.ServiceName) where !(from trans in db.Transactions select trans.ServiceId).Contains(service.ServiceId) select new SearchServiceResult { service_id = service.ServiceId, service_provider_id = service.ProviderId, service_provider_name = customer.FirstName + " " + customer.LastName, service_type = service.ServiceName, service_desc = service.Description, service_price = (decimal)service.Price }).Distinct(); // Check whether user input a minimum value or maximum value for price // if the user only input the minimum price, then only minimum price is set // if the user only input the maximum price, then only the maximum price is set // if the user input both minimum & maximum price, then the price range is set if (!(fromPrice == -12)) { theService = theService.Where(x => x.service_price >= fromPrice); } if (!(toPrice == -12)) { theService = theService.Where(x => x.service_price <= toPrice); } //List<SearchPetResult> test = petForSale.ToList(); //ViewData["petForSale"] = petForSale.ToList(); //SearchPetResult petForSaleModel = (SearchPetResult)petForSale; return View(theService.AsEnumerable()); }
public ActionResult PostService(Service cService) { //@ViewBag.Message = cPet.Description; //var cityId = Request.Form["citylist"]; Customer currentUser = (Customer)Session["currentUser"]; int customerId = currentUser.CustomerId; cService.ProviderId = customerId; db.Services.Add(cService); db.SaveChanges(); ViewBag.Message = "Your service has been posted. Thank you for using our service."; return View(); }
public ActionResult Edit(Service service) { if (ModelState.IsValid) { db.Entry(service).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.ProviderId = new SelectList(db.Customers, "CustomerId", "Username", service.ProviderId); return View(service); }
public ActionResult Selling(Pet cPet) { //@ViewBag.Message = cPet.Description; //var cityId = Request.Form["citylist"]; Customer currentUser = (Customer)Session["currentUser"]; int customerId = currentUser.CustomerId; cPet.CustomerId = customerId; if (cPet.Description == null) { cPet.Description = ""; } db.Pets.Add(cPet); db.SaveChanges(); Service newService = new Service(); newService.ProviderId = customerId; newService.PetId = cPet.PetId; newService.ServiceName = "Pet Selling by " + currentUser.FirstName + " " + currentUser.LastName; newService.Description = "Ordinary pet selling transaction"; newService.Price = cPet.Price; db.Services.Add(newService); db.SaveChanges(); ViewBag.Message = "Your pet info has been posted. Thank you for using our service."; return View(); }
public ActionResult PostFinding(Pet cPet) { Customer currentUser = (Customer)Session["currentUser"]; int customerId = currentUser.CustomerId; cPet.CustomerId = customerId; cPet.Price = 0; db.Pets.Add(cPet); db.SaveChanges(); Service newService = new Service(); newService.ProviderId = customerId; newService.PetId = cPet.PetId; newService.ServiceName = "A lost pet founded by " + currentUser.FirstName + " " + currentUser.LastName; newService.Description = "Found a lost pet"; newService.Price = 0; db.Services.Add(newService); db.SaveChanges(); ViewBag.Message = "Your pet info has been posted. Thank you for using our service."; return View(); }