コード例 #1
0
        public System.Web.Mvc.ActionResult CreateLabel(string strLabelName, string strColorName, string strFontColorName)
        {
            if (string.IsNullOrEmpty(strLabelName))
            {
                return Json(string.Empty);
            }
            else
            {
                LibraryLabel newLabel = new LibraryLabel();
                newLabel.Name = strLabelName;
                newLabel.UserId = CurrentUser.Details(User.Identity.Name).AccountId;
                try
                {
                    newLabel.LabelColor = ColorTranslator.FromHtml(strColorName);
                    newLabel.FontColor = ColorTranslator.FromHtml(strFontColorName);
                }
                catch (Exception)
                {
                    return Json(string.Empty);
                }

                long labelId = 0;
                string result = OBSDataSource.CreateLabel(out labelId, newLabel);
                if (string.IsNullOrEmpty(result))
                {
                    return Json(new { Id = labelId });
                }
                else
                {
                    return Json(string.Empty);
                }
            }
        }
コード例 #2
0
        public System.Web.Mvc.ActionResult UpdateLabel(string strLabelName, string strColorName, string strFontColorName, int nId)
        {
            if (string.IsNullOrEmpty(strLabelName) || string.IsNullOrEmpty(strColorName) || string.IsNullOrEmpty(strFontColorName))
            {
                return Json(string.Empty);
            }
            else
            {
                LibraryLabel newLabel = new LibraryLabel();
                newLabel.Name = strLabelName;
                newLabel.UserId = CurrentUser.Details(User.Identity.Name).AccountId;
                newLabel.ID = nId;
                try
                {
                    newLabel.LabelColor = ColorTranslator.FromHtml(strColorName);
                    newLabel.FontColor = ColorTranslator.FromHtml(strFontColorName);
                }
                catch (Exception)
                {
                    return Json(string.Empty);
                }

                string result = OBSDataSource.UpdateLabel(newLabel);
                if (string.IsNullOrEmpty(result))
                {
                    return Json(new { success = true });
                }
                else
                {
                    return Json(new { success = false });
                }
            }
        }