public ActionResult ReviewOrder(Campaign campaign, string discountcodes) { ReviewOrderViewModel reviewOrder = new ReviewOrderViewModel(); reviewOrder.Campaign = campaign; reviewOrder.TotalReviews = campaign.TextGoal + campaign.PhotoGoal + campaign.VideoGoal; reviewOrder.PaypalComment = String.Format("{0} High-Quality Reviews for ASIN: {1} - {2}", reviewOrder.TotalReviews, campaign.ASIN, campaign.Name); reviewOrder.DiscountCodes = discountcodes; PricingStructure pricing = (from p in db.PricingStructure select p).First(); //Note: We're only using textReviews right now, so photo and video will always be zero. However, // We want to take the number of text reviews and make 20% of them photovideo. if (campaign.TextGoal > 9) { double photos = campaign.TextGoal * .15; double videos = campaign.TextGoal * .05; campaign.PhotoGoal = Convert.ToInt32(Math.Round(photos)); campaign.VideoGoal = Convert.ToInt32(Math.Round(videos)); campaign.TextGoal = campaign.TextGoal - campaign.PhotoGoal - campaign.VideoGoal; } int textcount = campaign.TextGoal; int photocount = campaign.PhotoGoal; int videocount = campaign.VideoGoal; double textPrice = 0.00; double photoPrice = 0.00; double videoPrice = 0.00; //Note: if we were to implement Photo and Video pricing it would be here. if (reviewOrder.TotalReviews > 100) { textPrice = reviewOrder.TotalReviews * pricing.T3; } else if (reviewOrder.TotalReviews > 50 && reviewOrder.TotalReviews < 101) { textPrice = reviewOrder.TotalReviews * pricing.T2; } else { textPrice = reviewOrder.TotalReviews * pricing.T1; } double totalPrice = (textPrice + photoPrice + videoPrice); reviewOrder.TotalPrice = String.Format("${0:0.00}", totalPrice); reviewOrder.PaypalURL = reviewOrder.SetupPayment(); //Seller is going to leave site and go to Paypal to pay. We need to save the details so we can //implement them after payment is confirmed. Session.Add("NewCampaign", reviewOrder); return View(reviewOrder); }
public CampaignDetailsPageViewModel(Campaign camp) { Campaign = camp; CodesRemaining = (from c in db.DiscountCodes where c.CampaignID.Equals(Campaign.CampaignID) select c).Count(); Requests = new List<ItemRequestViewModel>() { }; foreach(var req in Campaign.ItemRequests) { ItemRequestViewModel rev = new ItemRequestViewModel(req); Requests.Add(rev); } }
public Campaign Update(Campaign campaign) { string[] ASIN = new string[] { campaign.ASIN }; List<dynamic> ids = new List<dynamic> { }; LookupByASIN generateData = new LookupByASIN(ASIN); ItemLookupResponse response = generateData.GetData(); foreach (var item in response.Items[0].Item) { List<dynamic> attributes = new List<dynamic>(); campaign.Name = item.ItemAttributes.Title; campaign.Category = item.ItemAttributes.Binding; campaign.ImageUrl = item.LargeImage.URL; string description = "Sorry, no description available."; if (item.EditorialReviews != null) { description = item.EditorialReviews[0].Content; description = Regex.Replace(description, @"<[^>]+>| ", "").Trim(); } campaign.Description = description; //Some Items have a price AND a sale price. We want the lower of the two. string regularprice = item.Offers.Offer[0].OfferListing[0].Price.Amount; string rawprice = regularprice; if (item.Offers.Offer[0].OfferListing[0].SalePrice != null) { string saleprice = item.Offers.Offer[0].OfferListing[0].SalePrice.Amount; if (int.Parse(saleprice) < int.Parse(regularprice)) { rawprice = saleprice; } } campaign.RetailPrice = (float.Parse(rawprice) / 100).ToString(); ; } return campaign; }
public ActionResult CreateOrder(string ASIN, string textReviews, string photoReviews, string videoReviews) { string[] asin = new string[] { ASIN }; ReadResponse processor = new ReadResponse(); Campaign campaign = new Campaign(); processor.Populate(campaign, asin); var exists = (from v in db.Vendors where v.CustomerID.Equals(User.Identity.Name) select v).First(); campaign.VendorID = exists.VendorId; if (String.IsNullOrEmpty(textReviews)) { textReviews = "0"; } if (String.IsNullOrEmpty(photoReviews)) { photoReviews = "0"; } if (String.IsNullOrEmpty(videoReviews)) { videoReviews = "0"; } campaign.TextGoal = int.Parse(textReviews); campaign.PhotoGoal = int.Parse(photoReviews); campaign.VideoGoal = int.Parse(videoReviews); return View(campaign); }
public ActionResult Edit(Campaign campaign, string discountcodes) { if (ModelState.IsValid) { campaign.SetNumericalPrices(); db.Entry(campaign).State = EntityState.Modified; //remove all discount codes in db first, then we'll re-add the ones //submitted on edit page var remove = from r in db.DiscountCodes where r.CampaignID.Equals(campaign.CampaignID) select r; if (remove != null) { db.DiscountCodes.RemoveRange(remove); db.SaveChanges(); } List<string> codes = discountcodes.Split(new[] { "\r\n" }, StringSplitOptions.None).ToList(); foreach (var item in codes) { if (!String.IsNullOrEmpty(item)) { DiscountCode itemcode = new DiscountCode(); itemcode.Code = item; itemcode.CampaignID = campaign.CampaignID; db.DiscountCodes.Add(itemcode); } } db.SaveChanges(); return RedirectToAction("Index"); } return View("Index", campaign); }
public ActionResult Validated(Campaign campaign, string discountcodes) { if (ModelState.IsValid) { campaign.SetNumericalPrices(); db.Campaigns.Add(campaign); db.SaveChanges(); int id = campaign.CampaignID; List<string> codes = discountcodes.Split(new[] { "\r\n" }, StringSplitOptions.None).ToList(); foreach (var item in codes) { if (!String.IsNullOrEmpty(item)) { DiscountCode itemcode = new DiscountCode(); itemcode.Code = item; itemcode.CampaignID = id; db.DiscountCodes.Add(itemcode); } } db.SaveChanges(); return RedirectToAction("Index"); } return View("Validate", campaign); }
public ActionResult Create(string asin) { if (asin == null) { return HttpNotFound(); } string[] ASIN = new string[] { asin }; ReadResponse processor = new ReadResponse(); Campaign campaign = new Campaign(); processor.Populate(campaign, ASIN); IOrderedQueryable<Vendor> vendors = db.Vendors .OrderBy(i => i.Name); ViewBag.VendorId = new SelectList(vendors, "VendorId", "Name", campaign.VendorID); return View("Validate", campaign); }