public ActionResult EditNetwork(Network net) { int idToCheck = net.Id; using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { var netOld = rdb.networks.Where(s => s.Id == idToCheck).FirstOrDefault(); netOld.Network = net.Name; rdb.Entry(netOld).State = System.Data.Entity.EntityState.Modified; rdb.SaveChanges(); string message = "Successfully Saved!"; if (Request.IsAjaxRequest()) { return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(null); } //RedirectToAction("RemoveRestaurant", "Admin"); //return View(); //return Content(Boolean.TrueString); } catch {//TODO: Log error //RedirectToAction("RemoveRestaurant", "Admin"); //return View(); return(Content(Boolean.FalseString)); } } }
public ActionResult RemoveNetwork(string id) { int idToCheck = Int32.Parse(id); string message; using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { var network = rdb.networks.Where(s => s.Id == idToCheck).FirstOrDefault(); rdb.networks.Remove(network); rdb.SaveChanges(); message = "Successfully removed!"; return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); //return View("AdminMenu"); //return RedirectToAction("RemoveRestaurant"); //return View(); //return Content(Boolean.TrueString); } catch {//TODO: Log error message = "Error"; return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); //return View("AdminMenu"); //return RedirectToAction("RemoveRestaurant"); //return View(); //return Content(Boolean.FalseString); } } }
public ActionResult EditDistrict(District ds) { int id = ds.Id; using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { var district = rdb.districts.Where(s => s.Id == id).FirstOrDefault(); district.District = ds.Name; rdb.Entry(district).State = System.Data.Entity.EntityState.Modified; rdb.SaveChanges(); string message = "Successfully Saved!"; if (Request.IsAjaxRequest()) { return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(null); } //return Content(Boolean.TrueString); } catch {//TODO: Log error return(Json(false)); //return Content(Boolean.FalseString); } } }
public ActionResult CreateDistrict(District ds) { string message = ""; using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { rdb.districts.Add(new districts { District = ds.Name, CityId = ds.CityId }); rdb.SaveChanges(); var id = rdb.districts.Where(s => s.District.Equals(ds.Name)).Select(s => s.Id); message = "Successfully Saved!" + id.ToString(); } catch { message = "Error! Please try again!"; } if (Request.IsAjaxRequest()) { return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(PartialView()); } } }
public ActionResult CreateNetwork(Network net) { string message = ""; using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { rdb.networks.Add(new networks { Network = net.Name }); rdb.SaveChanges(); var id = rdb.networks.Where(s => s.Network.Equals(net.Name)).Select(s => s.Id).ToList()[0]; message = "Successfully Saved!" + id.ToString(); } catch { message = "Error! Please try again!"; } if (Request.IsAjaxRequest()) { return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(PartialView()); } } }
public void RemoveComment(string id) { int idToCheck = Int32.Parse(id); using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { var comment = rdb.usercomments.Where(s => s.Id == idToCheck).FirstOrDefault(); rdb.usercomments.Remove(comment); rdb.SaveChanges(); } catch {//TODO: Log error } } }
public void UpdateComment(CustomLabelModel clm) { int id = clm.Id; using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { var comment = rdb.usercomments.Where(s => s.Id == id).FirstOrDefault(); comment.Comment = clm.LabelText; rdb.Entry(comment).State = System.Data.Entity.EntityState.Modified; rdb.SaveChanges(); } catch {//TODO: Log error } } }
public ActionResult RemoveDistrict(string id) { int idToCheck = Int32.Parse(id); using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { var district = rdb.districts.Where(s => s.Id == idToCheck).FirstOrDefault(); rdb.districts.Remove(district); rdb.SaveChanges(); return(Json(true)); //return Content(Boolean.TrueString); } catch {//TODO: Log error return(Json(false)); //return Content(Boolean.FalseString); } } }
public ActionResult RemoveReview(string id) { int idToCheck = Int32.Parse(id); string folderName = id; string message; using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { try { var rest = rdb.restaurants.Where(s => s.Id == idToCheck).FirstOrDefault(); rdb.restaurants.Remove(rest); rdb.SaveChanges(); //return Json(true); //return Content(Boolean.TrueString); message = "Successfully removed!"; var originalDirectory = new DirectoryInfo(string.Format("{0}images\\Restaurants\\" + "rest_" + folderName, Server.MapPath(@"\"))); string pathString = originalDirectory.ToString(); bool isExists = System.IO.Directory.Exists(pathString); if (isExists) { Directory.Delete(pathString, true); } return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch {//TODO: Log error //return Json(false); //return Content(Boolean.FalseString); message = "Error!"; return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } }
public ActionResult SaveLabel(CustomLabelModel lb) { string message = ""; if (ModelState.IsValid) { try { using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { rdb.usercomments.Add(new usercomments { Comment = lb.LabelText, DateOfCreation = DateTime.Now, RestaurantId = lb.ReviewID, UserName = lb.Name, Email = lb.E_mail }); rdb.SaveChanges(); message = "Successfully Saved!"; } } catch (Exception ex) { message = "Error. Please try egain!"; } } else { message = "Please provide required fields value."; } if (Request.IsAjaxRequest()) { return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { ViewBag.Message = message; return(View()); } }
public ActionResult CreateReview(AdminSaveModel rmd) { int?netId; if (rmd.NetworkId == null) { netId = 1; } else { netId = rmd.NetworkId; } string message; string hashtag = ""; if (rmd.ReviewText != null) { if (rmd.ReviewText.Contains('#')) { //get hashtag expression var regex = new Regex(@"(?<=#)\w+"); var matches = regex.Matches(rmd.ReviewText); StringBuilder stb = new StringBuilder(); foreach (Match m in matches) { stb.Append(m.Value); stb.Append(" "); } if (stb[stb.Length - 1].ToString().Equals(" ")) { stb.Remove(stb.Length - 1, 1); } hashtag = stb.ToString(); } } else { rmd.ReviewText = ""; } using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { double ln = double.Parse(rmd.Lng.Replace('.', ',')); double la = double.Parse(rmd.Lat.Replace('.', ',')); rdb.restaurants.Add(new restaurants { Address = rmd.Address, Children = rmd.Children, DateOfCreation = DateTime.Now, DistrictId = rmd.DistrictId, InteriorMark = rmd.InteriorMark, KitchenMark = rmd.KitchenMark, ServiceMark = rmd.ServiceMark, NetworkId = netId, Name = rmd.RestaurantName, Phones = rmd.Phones, Music = rmd.Music, Longitude = ln, Lattitude = la, KitchenType = rmd.KitchenType, Propositions = rmd.Propositions, ReviewText = rmd.ReviewText, SumAmount = rmd.Amount, WorkTime = rmd.WorkHours, CustomLabel = hashtag }); rdb.SaveChanges(); message = "Successfully Saved!"; if (Request.IsAjaxRequest()) { return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(null); } } }
public ActionResult EditReview(AdminSaveModel rmd) { int id = rmd.Id; string message; string hashtag = ""; try { //get hashtag expression var regex = new Regex(@"(?<=#)\w+"); var matches = regex.Matches(rmd.ReviewText); StringBuilder stb = new StringBuilder(); foreach (Match m in matches) { stb.Append(m.Value); stb.Append(" "); } if (stb[stb.Length - 1].ToString().Equals(" ")) { stb.Remove(stb.Length - 1, 1); } hashtag = stb.ToString(); } catch { } using (restaurants_dbEntities rdb = new restaurants_dbEntities()) { var rest = rdb.restaurants.Where(s => s.Id == id).FirstOrDefault(); if (rest != null) { rest.Address = rmd.Address; rest.Children = rmd.Children; rest.DateOfCreation = DateTime.Now; rest.DistrictId = rmd.DistrictId; rest.InteriorMark = rmd.InteriorMark; rest.KitchenMark = rmd.KitchenMark; rest.ServiceMark = rmd.ServiceMark; rest.NetworkId = rmd.NetworkId; rest.Name = rmd.RestaurantName; rest.Phones = rmd.Phones; rest.Music = rmd.Music; rest.Longitude = double.Parse(rmd.Lng.Replace('.', ',')); rest.Lattitude = double.Parse(rmd.Lat.Replace('.', ',')); rest.KitchenType = rmd.KitchenType; rest.Propositions = rmd.Propositions; rest.ReviewText = rmd.ReviewText; rest.SumAmount = rmd.Amount; rest.WorkTime = rmd.WorkHours; rest.CustomLabel = hashtag; } rdb.Entry(rest).State = System.Data.Entity.EntityState.Modified; rdb.SaveChanges(); message = "Successfully Saved!"; if (Request.IsAjaxRequest()) { return(new JsonResult { Data = message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } else { return(null); } } }