Ejemplo n.º 1
0
        public async Task <ResponseBase <bool> > ActualizaEstadoOrder(int IdOrden, int IdEstado)
        {
            var response = new ResponseBase <bool>();

            if (IdOrden > 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ROWCOUNT");

                repository.Parameters.Add("P_ORDID", OracleDbType.Int64).Value        = IdOrden;
                repository.Parameters.Add("P_IDESTADO", OracleDbType.Int16).Value     = IdEstado;
                repository.Parameters.Add("P_ROWCOUNT", OracleDbType.Int64).Direction = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_ORDERS.B2C_ORDERS_ACTUALIZA");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Orden actualizada correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field IdOrder or IdEstado is zero(0)";
            }

            return(await Task.Run(() => response));
        }
Ejemplo n.º 2
0
        public async Task <ResponseBase <Boolean> > DeleteCustomer(long id)
        {
            var response = new ResponseBase <Boolean>();

            if (id != 0)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_CUSTID");

                repository.Parameters.Add("P_CUSTID", OracleDbType.Varchar2, 200).Value = id;
                repository.Parameters.Add("P_ROWCOUNT", OracleDbType.Int64).Direction   = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_CUSTOMER.B2C_CUSTOMER_ELIMINAR");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Customer Eliminado correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = "The field Id is zero(0)";
            }
            return(await Task.Run(() => response));
        }
Ejemplo n.º 3
0
        public async Task <ResponseBase <Boolean> > UpdateCustomer(CustomerModel data)
        {
            data.Password = !string.IsNullOrWhiteSpace(data.Password) ? data.Password : "******";

            var response = new ResponseBase <Boolean>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                if (data.Password == "=====")
                {
                    data.Password = "";
                }
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_CUSTID");

                repository.Parameters.Add("P_CUSTID", OracleDbType.Int64).Value                   = data.CustId;
                repository.Parameters.Add("P_FNAME", OracleDbType.Varchar2, 200).Value            = data.FName;
                repository.Parameters.Add("P_LNAME", OracleDbType.Varchar2, 200).Value            = data.LName;
                repository.Parameters.Add("P_PHONENUMBER", OracleDbType.Varchar2, 200).Value      = data.PhoneNumber;
                repository.Parameters.Add("P_EMAIL", OracleDbType.Varchar2, 200).Value            = data.Email;
                repository.Parameters.Add("P_PASSWORD", OracleDbType.Varchar2, 200).Value         = data.Password;
                repository.Parameters.Add("P_CREDITCARDTYPE", OracleDbType.Varchar2, 200).Value   = data.CreditCardType;
                repository.Parameters.Add("P_CREDITCARDNUMBER", OracleDbType.Varchar2, 200).Value = data.CreditCardNumber;
                repository.Parameters.Add("P_STATUS", OracleDbType.Varchar2, 200).Value           = data.Status;
                repository.Parameters.Add("P_DOCNUMBER", OracleDbType.Varchar2).Value             = data.DocNumber;
                repository.Parameters.Add("P_USERNAME", OracleDbType.Varchar2, 200).Value         = data.UserName;
                repository.Parameters.Add("P_TIPOCLIENTE", OracleDbType.Varchar2, 200).Value      = data.ClientType;
                repository.Parameters.Add("P_ROWCOUNT", OracleDbType.Int64).Direction             = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_CUSTOMER.B2C_CUSTOMER_ACTUALIZAR");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Data    = true;
                    response.Message = "Customer Actualizado correctamente";
                }
                else
                {
                    response.Data    = false;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Ejemplo n.º 4
0
        public async Task <ResponseBase <long> > InsertOrder(OrderModel data)
        {
            var response = new ResponseBase <long>();
            var validate = ValidateMiddle.Result(data);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ORDID");

                repository.Parameters.Add("P_CUSTID", OracleDbType.Int64).Value        = data.CustId;
                repository.Parameters.Add("P_ORDENDATE", OracleDbType.Date, 200).Value = DateTime.Now;
                repository.Parameters.Add("P_PRICE", OracleDbType.Long, 200).Value     = data.Price;
                repository.Parameters.Add("P_IDESTADO", OracleDbType.Int16).Value      = 1;
                //repository.Parameters.Add("P_STATUS", OracleDbType.Varchar2).Value = data.Status;
                repository.Parameters.Add("P_COMMENTS", OracleDbType.Varchar2).Value = data.Comments;
                repository.Parameters.Add("P_ORDID", OracleDbType.Int64).Direction   = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_ORDERS.B2C_ORDERS_INSERT");
                if (repository.Status.Code == Status.Ok)
                {
                    var OrdId = Int64.Parse(repository.Parameters["P_ORDID"].Value.ToString());
                    foreach (var item in data.LItems)
                    {
                        item.OrdId    = OrdId;
                        item.IdEstado = 1;
                        InsertItem(item);
                    }
                    ;

                    response.Data    = OrdId;
                    response.Message = "Orden insertada correctamente";
                }
                else
                {
                    response.Data    = -1;
                    response.Message = repository.Status.Message;
                }
                response.Code = repository.Status.Code;
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(await Task.Run(() => response));
        }
Ejemplo n.º 5
0
        public async Task <ResponseBase <int> > GetCancelaProveedor()
        {
            var response = new ResponseBase <int>();

            IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ORDID");

            repository.Parameters.Add("P_ITEMID", OracleDbType.Int32).Value = 1;

            repository.SaveChanges("PKG_B2C_ORDERS.B2C_ORDERS_CANCELA_PROVEEDOR");
            if (repository.Status.Code == Status.Ok)
            {
                response.Data = 1;
            }
            else
            {
                response.Message = repository.Status.Message;
            }
            response.Code = repository.Status.Code;

            return(await Task.Run(() => response));
        }
Ejemplo n.º 6
0
        private ResponseBase <Boolean> InsertItem(ItemModel ObjItem)
        {
            var response = new ResponseBase <bool>();
            var validate = ValidateMiddle.Result(ObjItem);

            if (validate.Status)
            {
                IRepository <OracleParameterCollection> repository = new OracleRepository(connString, "P_ITEMID");

                repository.Parameters.Add("P_ORDID", OracleDbType.Int64).Value          = ObjItem.OrdId;
                repository.Parameters.Add("P_PRODID", OracleDbType.Int64).Value         = ObjItem.ProdId;
                repository.Parameters.Add("P_PRODUCTNAME", OracleDbType.Varchar2).Value = ObjItem.ProductName;
                repository.Parameters.Add("P_PARTNUM", OracleDbType.Varchar2).Value     = ObjItem.PartNum;
                repository.Parameters.Add("P_PRICE", OracleDbType.Long).Value           = ObjItem.Price;
                repository.Parameters.Add("P_QUANTITY", OracleDbType.Int16).Value       = ObjItem.Quantity;
                repository.Parameters.Add("P_IDESTADO", OracleDbType.Int16).Value       = ObjItem.IdEstado;
                repository.Parameters.Add("P_ITEMID", OracleDbType.Int64).Direction     = ParameterDirection.Output;

                repository.SaveChanges("PKG_B2C_ORDERS.B2C_ITEMS_INSERT");
                if (repository.Status.Code == Status.Ok)
                {
                    response.Code = Status.Ok;
                    response.Data = true;
                }
                else
                {
                    response.Code    = repository.Status.Code;
                    response.Message = repository.Status.Message;
                    response.Data    = false;
                }
            }
            else
            {
                response.Code    = Status.InvalidData;
                response.Message = validate.Message;
            }

            return(response);
        }