コード例 #1
0
        public void SendPurchaseOrder(Models.PurchaseOrder purchaseOrder)
        {
            SendMessage(purchaseOrder.Serialize(), "payment.purchaseorder");

            Console.WriteLine(" Purchase Order Sent {0}, £{1}, {2}, {3}",
                              purchaseOrder.CompanyName, purchaseOrder.Amount,
                              purchaseOrder.PaymentDayTerms, purchaseOrder.Number);
        }
コード例 #2
0
        public static Models.PurchaseOrder ConvertToPurchaseOrder(this PurchaseOrder purchaseOrder)
        {
            var ipo = (IPurchaseOrder)purchaseOrder;
            var po  = new Models.PurchaseOrder {
                OrderNumber = ipo.OrderNumber
            };

            return(purchaseOrder.ConvertToOrderGroup(po));
        }
コード例 #3
0
        public async Task <ActionResult <PurchaseOrder> > SavePurchaseOrder([FromBody] dynamic dto)

        {
            PurchaseOrderDTO _PurchaseOrderP = new PurchaseOrderDTO();
            PurchaseOrder    _PurchaseOrder  = new PurchaseOrder();


            try
            {
                _PurchaseOrderP = JsonConvert.DeserializeObject <PurchaseOrderDTO>(dto.ToString());
                _PurchaseOrder  = _PurchaseOrderP;
                string     baseadress = _config.Value.urlbase;
                HttpClient _client    = new HttpClient();
                _client.DefaultRequestHeaders.Add("Authorization", "Bearer " + HttpContext.Session.GetString("token"));
                var result = await _client.GetAsync(baseadress + "api/PurchaseOrder/GetPurchaseOrderById/" + _PurchaseOrder.Id);

                string valorrespuesta = "";
                _PurchaseOrder.FechaModificacion   = DateTime.Now;
                _PurchaseOrder.UsuarioModificacion = HttpContext.Session.GetString("user");
                _PurchaseOrder.BranchId            = Convert.ToInt32(HttpContext.Session.GetString("BranchId"));
                _PurchaseOrder.DatePlaced          = DateTime.Now;
                if (result.IsSuccessStatusCode)
                {
                    valorrespuesta = await(result.Content.ReadAsStringAsync());
                    _PurchaseOrder = JsonConvert.DeserializeObject <PurchaseOrder>(valorrespuesta);
                }

                if (_PurchaseOrder == null)
                {
                    _PurchaseOrder = new Models.PurchaseOrder();
                }

                if (_PurchaseOrderP.Id == 0)
                {
                    _PurchaseOrder.FechaCreacion   = DateTime.Now;
                    _PurchaseOrder.UsuarioCreacion = HttpContext.Session.GetString("user");

                    var insertresult = await Insert(_PurchaseOrderP);
                }

                else
                {
                    _PurchaseOrderP.UsuarioCreacion = _PurchaseOrder.UsuarioCreacion;
                    _PurchaseOrderP.FechaCreacion   = _PurchaseOrder.FechaCreacion;
                    var updateresult = await Update(_PurchaseOrder.Id, _PurchaseOrderP);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                throw ex;
            }

            return(Json(_PurchaseOrder));
        }
コード例 #4
0
        public object Delete(Models.PurchaseOrder deleted)
        {
            string msgError = "";
            bool   result   = repository.Remove(deleted, ref msgError);

            object json = new
            {
                success = result,
                message = msgError
            };

            return(json);
        }
コード例 #5
0
        public object Post(Models.PurchaseOrder added)
        {
            object json;
            string messageError = "";

            try
            {
                Models.PurchaseOrder posted = repository.Add(added, ref messageError);

                if (posted != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = posted,
                        success = true
                    };
                }
                else
                {
                    json = new
                    {
                        message = messageError,
                        success = false
                    };
                };
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                object error = new { message = ex.Message };

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }
コード例 #6
0
        public object GetAll()
        {
            var queryValues = Request.RequestUri.ParseQueryString();

            int page           = Convert.ToInt32(queryValues["page"]);
            int start          = Convert.ToInt32(queryValues["start"]);
            int limit          = Convert.ToInt32(queryValues["limit"]);
            int id             = Convert.ToInt32(queryValues["id"]);
            int orden          = Convert.ToInt32(queryValues["orden"]);
            int pOrderParentId = Convert.ToInt32(queryValues["POrderParentId"]);
            int qHeaderId      = Convert.ToInt32(queryValues["QHeaderId"]);


            #region Configuramos el orden de la consulta si se obtuvo como parametro
            string strOrder = !string.IsNullOrWhiteSpace(queryValues["sort"]) ? queryValues["sort"] : "";
            strOrder = strOrder.Replace('[', ' ');
            strOrder = strOrder.Replace(']', ' ');

            Sort sort;

            if (!string.IsNullOrWhiteSpace(strOrder))
            {
                sort = JsonConvert.DeserializeObject <Sort>(strOrder);
            }
            else
            {
                sort = new Sort();
            }
            #endregion

            string query = !string.IsNullOrWhiteSpace(queryValues["query"]) ? queryValues["query"] : "";

            int totalRecords = 0;

            try
            {
                if (id == 0)
                {
                    object json;
                    string msgError = "";
                    IList <Models.PurchaseOrder> lista;

                    lista = repository.GetList(qHeaderId, pOrderParentId, query, sort, page, start, limit, ref totalRecords, ref msgError);

                    json = new
                    {
                        total   = totalRecords,
                        data    = lista,
                        success = true
                    };

                    return(json);
                }
                else
                {
                    string msgError = "";
                    Models.PurchaseOrder estatus = repository.Get(id, ref msgError);

                    object json = new
                    {
                        data    = estatus,
                        success = true,
                        message = msgError
                    };

                    return(json);
                }
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                object error = new { message = ex.Message };

                object json = new
                {
                    message = ex.Message,
                    success = false
                };

                return(json);
            }
        }