public VendorEmailStatisticEntry(VendorStatisticsEntry entry) { this.Vendor = _context.Vendors.Where(x => x.Id == entry.VendorId).First(); if (entry.CategoryId == 0) this.CategoryName = "General List of ‘Suggested Service Providers‘"; else this.CategoryName = _context.Categories.Where(x => x.Id == entry.CategoryId).First().Title; this.OccurredAt = entry.OccurredAt; this.User = _context.UserPurchases.Where(x => x.Id == entry.UserId).First(); }
// // GET: /VendorClicksCounter/ public ActionResult Index(int vendorId, int categoryId) { VendorStatisticsEntry entry = new VendorStatisticsEntry(); entry.CategoryId = categoryId; entry.VendorId = vendorId; entry.Type = VendorStatisticsEntry.CLICK_TYPE; entry.OccurredAt = DateTime.Now; entry.UserId = _userRepository.GetUserByEmail(User.Identity.Name, (string)HttpContext.Session["facilityDateHash"]).Id; _context.VendorStatisticsEntries.Add(entry); _context.SaveChanges(); //TODO: generate link using something like URLConstructor(LinkToWebsite); return Redirect("http://" + _context.Vendors.Find(vendorId).LinkToWebsite); }
public ActionResult ContactMe(int vendorId, int categoryId) { VendorStatisticsEntry entry = new VendorStatisticsEntry(); entry.CategoryId = categoryId; entry.VendorId = vendorId; entry.Type = VendorStatisticsEntry.CONTACT_ME_TYPE; entry.OccurredAt = DateTime.Now; UserPurchase user = _userRepository.GetUserByEmail(User.Identity.Name, (string)HttpContext.Session["facilityDateHash"]); entry.UserId = user.Id; _context.VendorStatisticsEntries.Add(entry); _context.SaveChanges(); Vendor vendor = _context.Vendors.Find(vendorId); sendEmails(vendor, user, categoryId); return Content("success"); }