Exemplo n.º 1
0
        public IHttpActionResult GetVendorByID(int id)
        {
            var vendorFromDB = vendorDB.Get(id);

            if (vendorFromDB != null)
            {
                var result = vendorFromDB.AddLinks(
                    new HyperMedia {
                    Href = Url.Link("GetVendorByID", new { id = id }), Method = "GET", Rel = "Get one vendor by ID."
                },
                    new HyperMedia {
                    Href = Url.Link("GetVendors", null), Method = "GET", Rel = "Get all vendor."
                },
                    new HyperMedia {
                    Href = Url.Link("VendorRegistration", null), Method = "POST", Rel = "Create new vendor."
                }                                                                                                              //,
                    //new HyperMedia { Href = Url.Link("PutCustomer", null), Method = "PUT", Rel = "Update Customer" },
                    //new HyperMedia { Href = Url.Link("DeleteCustomer", null), Method = "DELETE", Rel = "Delete customer." }
                    );
                return(Ok(result));
            }
            else
            {
                return(StatusCode(HttpStatusCode.NotFound));
            }
        }
Exemplo n.º 2
0
        public void TestGet()
        {
            var    vendors      = vr.GetVendors();
            int    vendorscount = vendors.Count();
            Vendor C            = vr.Get(vendors[vendorscount - 1].Id);

            Assert.AreEqual(Comanche.Name, C.Name, "Name should be equal");
        }
Exemplo n.º 3
0
        public ActionResult VendorWithMaxBrand()
        {
            pchutEntities2 context1 = new pchutEntities2();
            var            list1    = context1.Database.SqlQuery <VendorMaxBrandViewModel>("select top 1 count(vendor_id) as NumberOfBrand, vendor_id from brand group by vendor_id order by count(vendor_id) desc").ToList();

            int?   id     = null;
            string amount = null;

            foreach (VendorMaxBrandViewModel i in list1)
            {
                id     = i.Vendor_id;
                amount = i.NumberOfBrand.ToString();
            }
            //int id = i
            ViewData["totalAmount"] = amount;

            VendorRepository vendor = new VendorRepository();
            var vendorInfo          = vendor.Get((int)id);

            return(View(vendorInfo));
        }