Beispiel #1
0
        public void SaveDetailQ(Token Token, int IdQ, RequestProducts Product)
        {
            using (SqlConnection con = new SqlConnection(this.ConnectionStrings))
            {
                using (SqlCommand cmd = new SqlCommand("GuardarCotizacionDetalle", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@IdPlanta", SqlDbType.Int);
                    cmd.Parameters["@IdPlanta"].Value = Token.IdPlant;

                    cmd.Parameters.Add("@IdCotizacion", SqlDbType.Int);
                    cmd.Parameters["@IdCotizacion"].Value = IdQ;

                    cmd.Parameters.Add("@IdProducto", SqlDbType.Int);
                    cmd.Parameters["@IdProducto"].Value = Product.Id;

                    cmd.Parameters.Add("@idMedida", SqlDbType.Int);
                    cmd.Parameters["@idMedida"].Value = Product.IdMeasure;

                    cmd.Parameters.Add("@Cantidad", SqlDbType.Decimal);
                    cmd.Parameters["@Cantidad"].Value = Product.Amount;

                    con.Open();

                    cmd.ExecuteNonQuery();
                }
            }
        }
 public virtual async Task <ListResult <ProductModel> > ListFiltered(RequestProducts request)
 {
     try
     {
         return(await Task.Run(() => _repository.ListFiltered(request)));
     }
     catch (Exception ex)
     {
         Log.Error(ex);
         return(new ListResult <ProductModel> {
             Status = "error", Message = ex.Message
         });
     }
 }
        public virtual ListResult <ProductModel> ListFiltered(RequestProducts request)
        {
            try
            {
                IQueryable <Product> query = from p in Context.Set <Product>()
                                             select p;

                query = query.OrderBy(string.IsNullOrEmpty(request.Sort) ? "Name" : request.Sort);

                if (request.SubcategoryID != null)
                {
                    query = query.Where(x => x.ProductSubcategoryID == request.SubcategoryID);
                }

                var page = query
                           .Skip(request.Skip ?? 0)
                           .Take(request.Take ?? 24)
                           .ToList();

                var pageViewModel = page.Select(x => Mapper.Map <Product, ProductModel>(x)).ToList();

                ListResult <ProductModel> result = new ListResult <ProductModel>
                {
                    Status     = "success",
                    TotalCount = query.Count(),
                    Records    = pageViewModel
                };

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(new ListResult <ProductModel> {
                    Status = "error", Message = ex.Message
                });
            }
        }