예제 #1
0
 public ActionResult Edit(Vendor vendor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vendor).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(vendor);
 }
예제 #2
0
        public ActionResult Create(Vendor vendor)
        {
            if (ModelState.IsValid)
            {
                vendor.JoinDate = DateTime.Now;
                db.Vendors.Add(vendor);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(vendor);
        }
예제 #3
0
        public SingleVendorViewModel(Vendor vendor)
        {
            Vendor = vendor;
            vendorsummary = new List<VendorSummaryViewModel> { };
            vendorsummary.Add(new VendorSummaryViewModel(vendor));

            var _camps = (from c in db.Campaigns
                          where c.VendorID.Equals(vendor.VendorId)
                          select c).ToList();

            vendorcampaigns = new CampaignIndexViewModel(_camps);

        }
예제 #4
0
        public ActionResult CreateSeller(Vendor vendor)
        {
            bool exists = (from v in db.Vendors
                           where v.CustomerID.Equals(User.Identity.Name)
                           select v).Any();

            if (exists)
            {
                return RedirectToAction("Index","Seller", new { message = "Already a Seller!" });
            }

            vendor.CustomerID = User.Identity.Name;

            if (ModelState.IsValid)
            {
                vendor.JoinDate = DateTime.Now;
                db.Vendors.Add(vendor);
                db.SaveChanges();
                return RedirectToAction("Index","Seller",new { message = "Seller Created!" });
            }

            return View(vendor);
        }
예제 #5
0
        public ActionResult CreateSeller()
        {
            string userId = User.Identity.Name;

            Customer selectedCust = (from cust in db.Customers
                                     where cust.CustomerID.Equals(userId)
                                     select cust).First();

            Vendor newVendor = new Vendor();
            newVendor.ContactName = selectedCust.FullName;
            newVendor.Email = selectedCust.Email;

            return View(newVendor);
        }
예제 #6
0
        public VendorSummaryViewModel(Vendor ven)
        {
            vendor = ven;

            var _camps = from c in db.Campaigns
                         where c.VendorID.Equals(vendor.VendorId)
                         select c;

            TotalCampaigns = _camps.Count();
            OpenCampaigns = _camps.Where(x => x.OpenCampaign.Equals(true)).Count();
            CompletedCampaigns = _camps.Where(x => x.OpenCampaign.Equals(false)).Count();

            var _revs = from r in db.Reviews
                        where r.Campaign.VendorID.Equals(vendor.VendorId)
                        select r;

            TotalReviews = _revs.Count();
            OpenReviews = _revs.Where(x => x.Reviewed.Equals(false)).Count();
            CompletedReviews = _revs.Where(x => x.Reviewed.Equals(true)).Count();

            _revs = _revs.Where(x => x.Reviewed.Equals(true));

            int stars = 0;
            int words = 0;
            int count = 0;
            foreach (var r in _revs.Where(x => x.Reviewed.Equals(true)))
            {
                count = count += 1;
                stars = stars + r.ProductRating.GetValueOrDefault();
                words = words + r.ReviewLength;
            }
            if (count > 0)
            {
                AvgWordCount = words / count;
                AvgProductRating = stars / count;
            }




        }