예제 #1
0
        public JsonResult CreateNews(NewsVM news)
        {
            try
            {
                _newsManager.AddNews(news);

                return(new JsonResult(new { success = true }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { success = false, msg = ex.Message }));
            }
        }
예제 #2
0
        public JsonResult AddNews(string title, string description)
        {
            bool          result = _newsManager.AddNews(title, description);
            MvcHtmlString jsonResult;

            if (result)
            {
                jsonResult = Alert.GetAlert(SetAlert.Set("Poprawnie dodano news!", "Sukcess", AlertType.Success));
            }
            else
            {
                jsonResult = Alert.GetAlert(SetAlert.Set("Wystąpił błąd, spróbuj ponownie później!", "Błąd", AlertType.Danger));
            }

            return(Json(jsonResult.ToHtmlString()));
        }