示例#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 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();
     }   
 }