public IActionResult enableDisable(int id, string UserId) { JsonResult result = new JsonResult(new { }); var objFromDb = _unitOfWork.AllowedLinks.GetAll().Where(s => (s.ActionLinkId == id && s.UserId == UserId)).FirstOrDefault(); if (objFromDb == null) { AllowedLinks obj = new AllowedLinks(); obj.UserId = UserId; obj.ActionLinkId = id; obj.IsAssinged = true; _unitOfWork.AllowedLinks.Add(obj); _unitOfWork.Save(); } else { if (objFromDb.IsAssinged == true) { objFromDb.IsAssinged = false; _unitOfWork.Save(); result.Value = new { Data = true }; return(result); } else if (objFromDb.IsAssinged == false) { objFromDb.IsAssinged = true; _unitOfWork.Save(); result.Value = new { Data = true }; return(result); } } result.Value = new { Data = false }; return(result); }
public bool IsLinkAllowed(MapEntityPrefab target) { if (target == null) { return(false); } return(AllowedLinks.Contains(target.Identifier) || target.AllowedLinks.Contains(identifier) || target.Tags.Any(t => AllowedLinks.Contains(t)) || Tags.Any(t => target.AllowedLinks.Contains(t))); }
public IActionResult Upsert(AllowedLinks link) { JsonResult result = new JsonResult(new { }); if (link.AllowedLinkId == 0) { _unitOfWork.AllowedLinks.Add(link); } else { _unitOfWork.AllowedLinks.Update(link); } _unitOfWork.Save(); result.Value = new { Data = true }; return(result); }
public bool IsLinkAllowed(MapEntityPrefab target) { if (target == null) { return(false); } if (target is StructurePrefab && AllowedLinks.Contains("structure")) { return(true); } if (target is ItemPrefab && AllowedLinks.Contains("item")) { return(true); } return(AllowedLinks.Contains(target.Identifier) || target.AllowedLinks.Contains(identifier) || target.Tags.Any(t => AllowedLinks.Contains(t)) || Tags.Any(t => target.AllowedLinks.Contains(t))); }
public IActionResult Upsert(int?id = 0) { AllowedLinks link = new AllowedLinks(); JsonResult result = new JsonResult(new { }); if (id == 0) { result.Value = new { Data = true, message = "Its Insert Call" }; return(result); } link = _unitOfWork.AllowedLinks.Get(id); if (link == null) { result.Value = new { Data = "Not Found" }; return(result); } result.Value = new { Data = link, message = "Its Update Call" }; return(result); }
private GUIComponent CreateEditingHUD(bool inGame = false) { editingHUD = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GUI.Canvas, Anchor.CenterRight) { MinSize = new Point(400, 0) }) { UserData = this }; GUIListBox listBox = new GUIListBox(new RectTransform(new Vector2(0.95f, 0.8f), editingHUD.RectTransform, Anchor.Center), style: null) { Spacing = 5 }; var itemEditor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true); if (!inGame && Linkable) { var linkText = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, 20)), TextManager.Get("HoldToLink"), font: GUI.SmallFont); var itemsText = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, 20)), TextManager.Get("AllowedLinks") + ": ", font: GUI.SmallFont); if (AllowedLinks.None()) { itemsText.Text += TextManager.Get("None"); } else { for (int i = 0; i < AllowedLinks.Count; i++) { itemsText.Text += AllowedLinks[i]; if (i < AllowedLinks.Count - 1) { itemsText.Text += ", "; } } } itemEditor.AddCustomContent(linkText, 1); itemEditor.AddCustomContent(itemsText, 2); linkText.TextColor = Color.Yellow; itemsText.TextColor = Color.Yellow; } if (!inGame && Sprite != null) { var reloadTextureButton = new GUIButton(new RectTransform(new Point(editingHUD.Rect.Width / 2, 20)), "Reload Texture"); reloadTextureButton.OnClicked += (button, data) => { Sprite.ReloadTexture(); return(true); }; itemEditor.AddCustomContent(reloadTextureButton, itemEditor.ContentCount); } foreach (ItemComponent ic in components) { if (inGame) { if (!ic.AllowInGameEditing) { continue; } if (SerializableProperty.GetProperties <InGameEditable>(ic).Count == 0) { continue; } } else { if (ic.requiredItems.Count == 0 && SerializableProperty.GetProperties <Editable>(ic).Count == 0) { continue; } } var componentEditor = new SerializableEntityEditor(listBox.Content.RectTransform, ic, inGame, showName: !inGame); if (inGame) { continue; } foreach (var kvp in ic.requiredItems) { foreach (RelatedItem relatedItem in kvp.Value) { var textBlock = new GUITextBlock(new RectTransform(new Point(editingHUD.Rect.Width, 20)), relatedItem.Type.ToString() + " required", font: GUI.SmallFont) { Padding = new Vector4(10.0f, 0.0f, 10.0f, 0.0f) }; componentEditor.AddCustomContent(textBlock, 1); GUITextBox namesBox = new GUITextBox(new RectTransform(new Vector2(0.5f, 1.0f), textBlock.RectTransform, Anchor.CenterRight)) { Font = GUI.SmallFont, Text = relatedItem.JoinedIdentifiers }; namesBox.OnDeselected += (textBox, key) => { relatedItem.JoinedIdentifiers = textBox.Text; textBox.Text = relatedItem.JoinedIdentifiers; }; namesBox.OnEnterPressed += (textBox, text) => { relatedItem.JoinedIdentifiers = text; textBox.Text = relatedItem.JoinedIdentifiers; return(true); }; } } } PositionEditingHUD(); SetHUDLayout(); return(editingHUD); }