Пример #1
0
        public IHttpActionResult Get(int id)
        {
            var result = _outputRepository.GetById(id);

            if (result != null)
            {
                return(Ok(result));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #2
0
        public bool Create(int id)
        {
            bool         success    = false;
            List <SumIV> queryGroup = new List <SumIV>();
            string       dateRec    = string.Empty; //Date Recepcion
            int          createLot  = 0;
            string       lote       = string.Empty;

            try
            {
                //Get IVDOCNBR
                Common common   = new Common();
                string IVDOCNBR = string.Format("MST{0}",
                                                common.getNextNumber("selSI_NextNumber", "selSI_IV40100", "selSI_IV_TYPE_ID", "MST"));

                Output _output = _outRepository.GetById(id);

                //Wrapper
                XDocument doc =
                    new XDocument(
                        new XElement("eConnect",
                                     new XElement("IVInventoryTransactionType",
                                                  new XElement("taIVTransactionLotInsert_Items", string.Empty),
                                                  new XElement("taIVTransactionLineInsert_Items", string.Empty),
                                                  new XElement("taIVTransactionHeaderInsert",
                                                               new XElement("BACHNUMB", "MST" + DateTime.Now.ToString("ddMMHHmmss")),
                                                               new XElement("IVDOCNBR", IVDOCNBR),
                                                               new XElement("IVDOCTYP", 1),
                                                               new XElement("DOCDATE", DateTime.Now.ToShortDateString())
                                                               )
                                                  )
                                     )
                        );

                List <OutputDetail> itemsList = _output.Details.Where(a => a.Quantity > 0).ToList();

                foreach (OutputDetail row in itemsList)
                {
                    //Evaluamos si se incrementa o disminuye la cantidad
                    int  qty;
                    int  adjType;
                    bool negative = true;
                    lote = "MST" + DateTime.Now.ToString("dd/MM/yy");

                    bool createItemPositive = false;
                    bool createLineX        = false;
                    //qty = (row.Quantity);
                    queryGroup = GetLotIV00300(row.ProductCode.Trim(), row.Warehouse.Trim(), row.Quantity);



                    adjType   = 1;
                    createLot = 0;

                    foreach (var item in queryGroup)
                    {
                        XElement lot = new XElement("taIVTransactionLotInsert",
                                                    new XElement("IVDOCNBR", IVDOCNBR),
                                                    new XElement("IVDOCTYP", 1),
                                                    new XElement("ITEMNMBR", row.ProductCode),
                                                    new XElement("LOTNUMBR", item.lotnumbr.Trim()),
                                                    new XElement("SERLTQTY", item.qtyrecvd.ToString().Replace(".00000", "")),
                                                    new XElement("ADJTYPE", adjType),
                                                    new XElement("LOCNCODE", row.Warehouse.Trim()),
                                                    new XElement("DATERECD", item.DATERECD.ToString("dd/MM/yy HH:mm:ss")),
                                                    new XElement("AUTOCREATELOT", createLot));

                        doc.Descendants()
                        .Where(p => p.Name.LocalName == "taIVTransactionLotInsert_Items")
                        .FirstOrDefault()
                        .Add(lot);

                        XElement line = new XElement("taIVTransactionLineInsert",
                                                     new XElement("IVDOCNBR", IVDOCNBR),
                                                     new XElement("IVDOCTYP", 1),
                                                     new XElement("ITEMNMBR", row.ProductCode),
                                                     new XElement("TRXQTY", (item.qtyrecvd * -1).ToString().Replace(".00000", "")),
                                                     new XElement("TRXLOCTN", row.Warehouse.Trim()));

                        doc.Descendants()
                        .Where(p => p.Name.LocalName == "taIVTransactionLineInsert_Items")
                        .FirstOrDefault()
                        .Add(line);
                    }
                }

                doc.Save(string.Format("{0}MST{1}.xml", Settings.Default.XmlFolderPath,
                                       DateTime.Now.ToString("yyyyMMddTHHmmss")));

                success = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }

            return(success);
        }