Esempio n. 1
0
        public JsonResult ObtenerItem(int id)
        {
            var dbHelper = new ItemsHelper(ItemsHelper.GetConnection());
            var item     = dbHelper.ObtenerItem(id);

            return(Json(item, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public static void ShowItemUi(this Character charData, bool refreshOnly = false, bool withMessage = true)
        {
            IEnumerable <Entities.Item.ItemEntity> playerItems =
                ItemsHelper.GetItemsByOwner(OwnerType.Player, charData.Id);
            List <ClientItem> pItems = playerItems.Select(t => new ClientItem(t.Id, t.Name, t.Used)).ToList();

            charData.PlayerHandle.TriggerEvent(refreshOnly ? "client.items.refreshItems" : "client.items.showItems",
                                               JsonConvert.SerializeObject(pItems, Formatting.None));
        }
Esempio n. 3
0
        public ActionResult GuardarItem(Item item)
        {
            item.EmpresaId = 2;             //todo
            item.Activo    = true;
            var dbHelper = new ItemsHelper(ItemsHelper.GetConnection());
            var message  = dbHelper.GuardarItem(item);

            return(Json(item));
        }
Esempio n. 4
0
        public JsonResult ObtenerItems()
        {
            var id_e = Convert.ToInt32(HttpContext.GetOwinContext().Authentication.User.Claims
                                       .FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value);

            var dbHelper = new ItemsHelper(ItemsHelper.GetConnection());
            var items    = dbHelper.ObtenerItems(id_e);         //todo: obtener correctamente el id

            return(Json(items, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public void CmdItem(Client player, string args = "")
        {
            Character charData = Account.GetPlayerData(player);

            if (charData == null)
            {
                return;
            }

            string[] arguments = Command.GetCommandArguments(args);
            if (arguments.Length == 0)
            {
                // Library.ShowUi(player);
                charData.ShowItemUi();
                return;
            }

            if (arguments[0].ToLower() == "podnies")
            {
                // TODO in vehicle
                IEnumerable <ItemEntity> itemsList =
                    ItemsHelper.GetItemsInSphere(player.Position, 5.0, (int)player.Dimension);
                if (!itemsList.Any())
                {
                    Ui.ShowError(player, "Obok Ciebie nie leżą żadne przedmioty.");
                    return;
                }

                List <DialogColumn> dialogColumns = new List <DialogColumn>
                {
                    new DialogColumn("Przedmiot", 90)
                };
                List <DialogRow> dialogRows = itemsList
                                              .Select(entry => new DialogRow(entry.Id, new[] { $"{entry.Name} (UID: {entry.Id})" })).ToList();

                string[] dialogButtons = { "Podnieś", "Anuluj" };
                Features.Dialogs.Library.CreateDialog(player, DialogId.ItemPickDialog, "Podnoszenie przedmiotu",
                                                      dialogColumns,
                                                      dialogRows, dialogButtons);
            }
            else
            {
                charData.ShowItemUi();
            }
        }
        public async Task <OperationResult> ImportUnit(UnitImportModel unitAsJson)
        {
            try
            {
                {
                    JToken rawJson        = JRaw.Parse(unitAsJson.ImportList);
                    JToken rawHeadersJson = JRaw.Parse(unitAsJson.Headers);

                    JToken headers = rawHeadersJson;
                    IEnumerable <JToken> itemObjects = rawJson.Skip(1);

                    foreach (JToken itemObj in itemObjects)
                    {
                        bool numberExists   = int.TryParse(headers[0]["headerValue"].ToString(), out int numberColumn);
                        bool itemNameExists = int.TryParse(headers[1]["headerValue"].ToString(),
                                                           out int nameColumn);
                        if (numberExists || itemNameExists)
                        {
                            Item existingItem = FindItem(numberExists, numberColumn, itemNameExists,
                                                         nameColumn, headers, itemObj);
                            if (existingItem == null)
                            {
                                ItemsListPnItemModel itemModel =
                                    ItemsHelper.ComposeValues(new ItemsListPnItemModel(), headers, itemObj);

                                Item newItem = new Item
                                {
                                    ItemNumber   = itemModel.ItemNumber,
                                    Name         = itemModel.Name,
                                    Description  = itemModel.Description,
                                    LocationCode = itemModel.LocationCode,
                                };
                                await newItem.Save(_dbContext);
                            }
                            else
                            {
                                if (existingItem.WorkflowState == Constants.WorkflowStates.Removed)
                                {
                                    Item item = await _dbContext.Items.SingleOrDefaultAsync(x => x.Id == existingItem.Id);

                                    if (item != null)
                                    {
                                        item.Name          = existingItem.Name;
                                        item.Description   = existingItem.Description;
                                        item.ItemNumber    = existingItem.ItemNumber;
                                        item.LocationCode  = existingItem.LocationCode;
                                        item.WorkflowState = Constants.WorkflowStates.Created;

                                        await item.Update(_dbContext);
                                    }
                                }
                            }
                        }
                    }
                }
                return(new OperationResult(true,
                                           _itemsPlanningLocalizationService.GetString("ItemImportes")));
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
                _coreHelper.LogException(e.Message);
                return(new OperationResult(false,
                                           _itemsPlanningLocalizationService.GetString("ErrorWhileImportingItems")));
            }
        }
Esempio n. 7
0
 public bool HasItemTypeUsed(ItemType itemType)
 {
     return(ItemsHelper.DoesCharacterHasItemTypeUsed(this, itemType));
 }