public IActionResult SaveCustomLabel(CustomLabelModel customLabelModel)
        {
            var customLabel = customLabelModel.Id > 0
                ? _customLabelService.Get(customLabelModel.Id)
                : new CustomLabel();

            if (customLabel == null)
            {
                return(NotFound());
            }
            customLabel.Text = customLabelModel.Text;
            customLabel.Type = customLabelModel.LabelType;
            _customLabelService.InsertOrUpdate(customLabel);
            return(R.Success.Result);
        }
Example #2
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
                }
            }
        }
Example #3
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());
            }
        }