Exemplo n.º 1
0
        public ActionResult SwapListItemControl(string jsonvalue, string Id, string type)
        {
            var list           = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
            var firstOrDefault = list.FirstOrDefault(organizationIp => organizationIp.Value.Equals(Id));

            if (firstOrDefault == null)
            {
                return(Content(""));
            }
            switch (type)
            {
            case "Up":
                var orDefaultdown = list.OrderByDescending(x => x.Order).FirstOrDefault(control => control.Order < firstOrDefault.Order);
                if (orDefaultdown == null)
                {
                    return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                }
                var orderdown = firstOrDefault.Order;
                firstOrDefault.Order = orDefaultdown.Order;
                orDefaultdown.Order  = orderdown;
                break;

            case "Down":
                var orDefault = list.OrderBy(x => x.Order).FirstOrDefault(control => control.Order > firstOrDefault.Order);
                if (orDefault == null)
                {
                    return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                }
                var order = (firstOrDefault).Order;
                firstOrDefault.Order = orDefault.Order;
                orDefault.Order      = order;
                break;
            }
            return(Json(new { Result = true, Value = list.SerializeListItem().Compress() }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
 public void FillListItems(string value, object obj)
 {
     if (obj.GetType().BaseType == typeof(ListControl))
     {
         ((ListControl)obj).Items = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(StringUtils.Decrypt(value).Decompress()));
     }
 }
Exemplo n.º 3
0
        public ActionResult GeneratListItemHtml(string jsonvalue)
        {
            var list = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(jsonvalue.Decompress()));

            ViewBag.jsonvalue = jsonvalue;
            return(PartialView("PartialViewListItemModify", list));
        }
Exemplo n.º 4
0
        public ActionResult GetListItemControlPanel(FormCollection collection)
        {
            try
            {
                var multiselect = collection["multiselect"].ToBool();
                var list        = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(collection["jsonvalue"].Decompress()));
                var listItem    = new ListItem();
                this.RadynTryUpdateModel(listItem);
                if (string.IsNullOrEmpty(listItem.Value))
                {
                    if (!string.IsNullOrEmpty(listItem.Text))
                    {
                        listItem.Value = listItem.Text;
                    }
                    else
                    {
                        ShowMessage(Resources.FormGenerator.YouCanSelectOnlyOneItemSelected, Resources.Common.MessaageTitle, messageIcon: MessageIcon.Error);
                        return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                    }
                }
                var firstOrDefault = list.FirstOrDefault(ip => ip.Value.Equals(listItem.Value));
                if (firstOrDefault == null)
                {
                    if (listItem.Selected && !multiselect)
                    {
                        if (list.Any(x => x.Selected && x.Value != listItem.Value))
                        {
                            ShowMessage(Resources.FormGenerator.YouCanSelectOnlyOneItemSelected, Resources.Common.MessaageTitle,
                                        messageIcon: MessageIcon.Error);
                            return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
                        }
                    }
                    listItem.Order = list.Count == 0 ? 1 : list.Max(x => x.Order) + 1;
                    list.Add(listItem);
                }
                else
                {
                    this.RadynTryUpdateModel(firstOrDefault);

                    if (firstOrDefault.Selected && !multiselect)
                    {
                        if (list.Any(x => x.Selected && x.Value != firstOrDefault.Value))
                        {
                            ShowMessage(Resources.Common.ErrorInInsert, Resources.Common.MessaageTitle,
                                        messageIcon: MessageIcon.Error);
                            return(Content(""));
                        }
                    }
                }
                return(Json(new { Result = true, Value = list.SerializeListItem().Compress() }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                ShowExceptionMessage(exception);
                return(Json(new { Result = false, Value = "" }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 5
0
        public ActionResult DeleteListItemControl(string jsonvalue, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(Json(new { Result = true, Value = "" }, JsonRequestBehavior.AllowGet));
            }
            var list           = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
            var firstOrDefault = list.FirstOrDefault(x => x.Value == value);

            if (firstOrDefault != null)
            {
                list.Remove(firstOrDefault);
            }
            return(Json(new { Result = true, Value = list.SerializeListItem().Compress() }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public ActionResult GetListItemControlPanel(string jsonvalue, string value, bool multiselect = false)
        {
            ListItem item = null;

            if (!string.IsNullOrEmpty(value))
            {
                var list           = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(jsonvalue.Decompress()));
                var firstOrDefault = list.FirstOrDefault(x => x.Value == value);
                if (firstOrDefault != null)
                {
                    item = firstOrDefault;
                }
            }
            else
            {
                item = new ListItem()
                {
                    Enable = true
                }
            };
            ViewBag.jsonvalue   = jsonvalue;
            ViewBag.multiselect = multiselect;
            return(PartialView("PartialViewListItemControls", item));
        }
Exemplo n.º 7
0
        public ActionResult GetListItemCount(string value)
        {
            var deSerializeListItem = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(StringUtils.Decrypt(value).Decompress()));

            return(Json(new { CountItem = deSerializeListItem.Count, Added = deSerializeListItem.Count > 0 }, JsonRequestBehavior.AllowGet));
        }