public ActionResult Edit([Bind(Include = "RestID,Restaurant,Address,City,Rating,Cuisine,Created,Modified")] RestaurantsClass restaurantsClass) { if (ModelState.IsValid) { crud.Update(restaurantsClass); return RedirectToAction("Index"); } return View(restaurantsClass); }
// GET: RestaurantsClasses/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } RestaurantsClass restaurantsClass = crud.getID(id); if (restaurantsClass == null) { return HttpNotFound(); } return View(restaurantsClass); }
public List <RestaurantsClass> GetAllRestDealsById(int id) { List <RestaurantsClass> li = new List <RestaurantsClass>(); var Ps = obj.RestaurantsDeals.Where(x => x.RestId.Equals(id)).ToList(); var count = Ps.Count(); foreach (var details in Ps) { RestaurantsClass temp = new RestaurantsClass(); temp.DealId = details.DealsId; temp.Count = count; li.Add(temp); } return(li); }
public int PostRestaurant(RestaurantsClass RC) { int check = 0; try { Restaurant Restaurants = new Restaurant(); Restaurants.Name = RC.Name; Restaurants.Area = RC.Area; Restaurants.Discount = RC.Discount; Restaurants.Status = 1; Restaurants.AddDate = DateTime.Now.ToShortDateString(); obj.Restaurants.InsertOnSubmit(Restaurants); obj.SubmitChanges(); check = Restaurants.Id; } catch (Exception e) { check = 0; } return(check); }
public List <RestaurantsClass> GetAllRestaurants() { int id = 0; int ShowRecords = 20; int skip = id * ShowRecords; var DesiMasala = ""; var AllRecords = obj.Restaurants.Count(); int max = (skip + ShowRecords); if (max > AllRecords) { max = AllRecords; } DesiMasala = (skip + 1).ToString() + "-" + max.ToString() + "/" + AllRecords.ToString(); List <RestaurantsClass> li = new List <RestaurantsClass>(); var AllRestaurants = obj.Restaurants.Skip(skip).Take(ShowRecords).Where(x => x.Status != 0).ToList(); var count = AllRestaurants.Count(); foreach (var details in AllRestaurants) { RestaurantsClass temp = new RestaurantsClass(); temp.Id = details.Id; temp.Name = details.Name; temp.Area = details.Area; try { temp.Discount = details.Discount.Value; } catch (Exception e) { temp.Discount = 0; } temp.Count = count; temp.NumberOfShowing = DesiMasala; li.Add(temp); } return(li); }
public List <RestaurantsClass> GetAllRestaurantsById(int id) { List <RestaurantsClass> li = new List <RestaurantsClass>(); var AllRestaurants = obj.Restaurants.Where(x => x.Status != 0 && x.Id.Equals(id)).ToList(); var count = AllRestaurants.Count(); foreach (var details in AllRestaurants) { RestaurantsClass temp = new RestaurantsClass(); temp.Id = details.Id; temp.Name = details.Name; temp.Area = details.Area; try { temp.Discount = details.Discount.Value; } catch (Exception e) { temp.Discount = 0; } temp.Count = count; li.Add(temp); } return(li); }
public int UpdateRestaurant(RestaurantsClass RC) { int check = 0; try { Restaurant Restaurants = obj.Restaurants.First(x => x.Id.Equals(RC.Id)); Restaurants.Name = RC.Name; Restaurants.Area = RC.Area; Restaurants.Discount = RC.Discount; Restaurants.Status = 1; obj.SubmitChanges(); check = Restaurants.Id; List <ResataurantTag> rt = obj.ResataurantTags.Where(x => x.RestId.Equals(Restaurants.Id)).ToList(); obj.ResataurantTags.DeleteAllOnSubmit(rt); obj.SubmitChanges(); List <RestaurantsDeal> rd = obj.RestaurantsDeals.Where(x => x.RestId.Equals(Restaurants.Id)).ToList(); obj.RestaurantsDeals.DeleteAllOnSubmit(rd); obj.SubmitChanges(); } catch (Exception e) { check = 0; } return(check); }
public ActionResult DeleteConfirmed(int id) { RestaurantsClass restaurantsClass = crud.getID(id); crud.Delete(restaurantsClass); return RedirectToAction("Index"); }