示例#1
0
        public async Task <IActionResult> OpInventory([FromRoute] Guid uid, [FromBody] invops_inventory varinvops_inv)
        {
            TerminalMessage result = new TerminalMessage();

            result.message = await _terminalService.Operation_inventory(uid, varinvops_inv);

            return(Ok(result));
        }
示例#2
0
        public async Task <string> Operation_inventory(Guid uid, invops_inventory varinvops_in)
        {
            string result = "";

            invp_data m = null;
            invp_tag  t;

            t = _context.invp_tag.FirstOrDefault(t => t.RFID == varinvops_in.rfid);
            if (t == null)
            {
                result = "Метка не зарегистрирована. ";
            }

            if (t != null)
            {
                m = _context.invp_data.FirstOrDefault(z => z.invp_dataId == t.invp_dataId);
                if (m == null)
                {
                    result += "Запчасть не обнаружена. ";
                }
            }

            invwh_cell c = null;

            c = _context.invwh_cell.FirstOrDefault(cc => cc.SHCODE == varinvops_in.shCode);
            if (c == null)
            {
                result += "Ячейка не найдена. ";
            }



            if (varinvops_in.quantity <= 0)
            {
                result += "Количество должно быть положительным числом. ";
            }

            if (t != null && m != null && c != null && varinvops_in.quantity > 0)
            {
                invwh_loc loc = null;
                loc = _context.invwh_loc.FirstOrDefault(l => l.invwh_locId == c.invwh_locId);

                inva_real e = null;

                {
                    e             = new inva_real();
                    e.inva_realId = Guid.NewGuid();
                    e.inva_infoId = varinvops_in.InventoryID;
                    e.Qty         = varinvops_in.quantity;
                    e.storepartid = m.invp_dataId;
                    e.locationid  = c.invwh_locId;
                    e.cellid      = c.invwh_cellId;
                    e.RFID        = varinvops_in.rfid;
                    if (loc != null)
                    {
                        e.theStore = loc.theStore;
                    }
                    _context.inva_real.Add(e);
                }

                await _context.SaveChangesAsync();

                return("OK");
            }
            else
            {
                await _context.SaveChangesAsync();

                return(result);
            }
        }