コード例 #1
0
 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	
         }
     }
 }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        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;
                }

            }
        }