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)); }
public void FillListItems(string value, object obj) { if (obj.GetType().BaseType == typeof(ListControl)) { ((ListControl)obj).Items = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(StringUtils.Decrypt(value).Decompress())); } }
public ActionResult GeneratListItemHtml(string jsonvalue) { var list = Extentions.DeSerializeListItem(Utils.ConvertHtmlToString(jsonvalue.Decompress())); ViewBag.jsonvalue = jsonvalue; return(PartialView("PartialViewListItemModify", list)); }
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)); } }
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)); }
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)); }
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)); }