Ejemplo n.º 1
0
        public void SetDropDownList()
        {
            using (var ctx = new ProductMNEntities())
            {
                var cateDomain = new CategoryDomain(ctx);
                var supDomain  = new SupplierDomain(ctx);

                var suppliers = supDomain.GetAll().Select(s => new DropDownListVMs
                {
                    Text  = s.CompanyName,
                    Value = s.SupplierID.ToString()
                }).ToList();

                var categories = cateDomain.GetAll().Select(c => new DropDownListVMs
                {
                    Text  = c.CategoryName,
                    Value = c.CategoryID.ToString()
                }).ToList();

                var discontinueds = new List <DropDownListVMs>
                {
                    new DropDownListVMs
                    {
                        Text  = "True",
                        Value = "true"
                    },
                    new DropDownListVMs
                    {
                        Text  = "False",
                        Value = "false"
                    },
                };

                Suppliers_ID.DataTextField  = "Text";
                Suppliers_ID.DataValueField = "Value";
                Suppliers_ID.DataSource     = suppliers;
                Suppliers_ID.DataBind();

                Categories_ID.DataTextField  = "Text";
                Categories_ID.DataValueField = "Value";
                Categories_ID.DataSource     = categories;
                Categories_ID.DataBind();

                Discountinued.DataTextField  = "Text";
                Discountinued.DataValueField = "Text";
                Discountinued.DataSource     = discontinueds;
                Discountinued.DataBind();
            }
        }
        public async Task <SupplierDomain> UpdateAsync(SupplierDomain supplier)
        {
            var existingSupplier = await GetSupplierEntityAsync(supplier.Id).ConfigureAwait(false);

            if (existingSupplier is null)
            {
                throw new EntityNotFoundException($@"Unable to find supplier {supplier.Id} to update");
            }

            _mapper.Map(supplier, existingSupplier);

            try
            {
                await _databaseContext.SaveChangesAsync().ConfigureAwait(false);

                return(existingSupplier.ToDomain());
            }
            catch (Exception)
            {
                throw new DbSaveFailedException("Could not save supplier to database");
            }
        }
Ejemplo n.º 3
0
        // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        public List <SupplierDomain> GetByCategoryIdAndRadiusAndDesignation(ProductByCategoryRequest model)
        {
            List <SupplierDomain> companyList = null;

            try
            {
                DataProvider.ExecuteCmd(GetConnection, "dbo.Suppliers_GetByCategoryIdAndRadiusAndDesignation"
                                        , inputParamMapper : delegate(SqlParameterCollection paramCollection)
                {
                    paramCollection.AddWithValue("@CategoryId", model.CategoryId);
                    paramCollection.AddWithValue("@latpoint", model.Latitude);
                    paramCollection.AddWithValue("@lngpoint", model.Longitude);
                    paramCollection.AddWithValue("@radius", model.Radius);
                    paramCollection.AddWithValue("@designations", model.Designations);
                }
                                        , map : delegate(IDataReader reader, short set)
                {
                    SupplierDomain singleCompany = new SupplierDomain();

                    int startingIndex = 0;  //startingOrdinal

                    singleCompany.CompanyName        = reader.GetSafeString(startingIndex++);
                    singleCompany.Designations       = reader.GetSafeInt32(startingIndex++);
                    singleCompany.URL                = reader.GetSafeString(startingIndex++);
                    singleCompany.Email              = reader.GetSafeString(startingIndex++);
                    singleCompany.MediaUrl           = reader.GetSafeString(startingIndex++);
                    singleCompany.Phone              = reader.GetSafeString(startingIndex++);
                    singleCompany.CompanyId          = reader.GetSafeInt32(startingIndex++);
                    singleCompany.ProductName        = reader.GetSafeString(startingIndex++);
                    singleCompany.Category           = reader.GetSafeString(startingIndex++);
                    singleCompany.ProductDescription = reader.GetSafeString(startingIndex++);
                    singleCompany.Cost               = reader.GetSafeDecimal(startingIndex++);
                    singleCompany.Quantity           = reader.GetSafeInt32(startingIndex++);
                    singleCompany.Threshold          = reader.GetSafeInt32(startingIndex++);
                    singleCompany.MinPurchase        = reader.GetSafeInt32(startingIndex++);
                    singleCompany.ProductMediaId     = reader.GetSafeInt32(startingIndex++);
                    singleCompany.CategoryId         = reader.GetSafeInt32(startingIndex++);
                    singleCompany.Latitude           = reader.GetSafeDecimal(startingIndex++);
                    singleCompany.Longitude          = reader.GetSafeDecimal(startingIndex++);
                    singleCompany.Address1           = reader.GetSafeString(startingIndex++);
                    singleCompany.City               = reader.GetSafeString(startingIndex++);
                    singleCompany.State              = reader.GetSafeString(startingIndex++);
                    singleCompany.ZipCode            = reader.GetSafeString(startingIndex++);
                    singleCompany.distance_in_mi     = (decimal)reader.GetSafeDouble(startingIndex++);


                    if (companyList == null)
                    {
                        companyList = new List <SupplierDomain>();
                    }

                    companyList.Add(singleCompany);
                }
                                        );
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(companyList);
        }
Ejemplo n.º 4
0
 public static SupplierResponse ToResponse(this SupplierDomain supplierDomain)
 {
     return(_mapper.Map <SupplierResponse>(supplierDomain));
 }