public ActionResult AddMessage(string message, string categoryUrl, string subcategoryUrl, string goodUrl, string goodName, int discussionGroup) { using (GoodContext db = new GoodContext()) { ViewBag.CategoriesData = GetCategoriesData(); if (db.GoodCategories.Where(x => x.CategoryUrl == categoryUrl).Any() && db.GoodSubcategories.Where(x => x.SubcategoryUrl == subcategoryUrl).Any() && db.Goods.Where(x => x.GoodUrl == goodUrl).Any()) { Discussion newDiscussion = new Discussion { AuthorName = "Viktor Chugunov", AuthorAvatarSrc = "", Date = DateTime.Now.Date.ToUniversalTime(), Message = message, FirstDiscussionMessage = discussionGroup == -1 ? true : false, DiscussionGroup = discussionGroup == -1 ? db.Discussions.Select(p => p.DiscussionGroup).Max() + 1 : discussionGroup }; db.Discussions.Add(newDiscussion); List <Good> goodList = db.Goods.Where(x => x.GoodName == goodName).ToList(); foreach (var item in goodList) { Good good = db.Goods.Find(item.Id); good.Discussions.Add(newDiscussion); } db.SaveChanges(); return(Redirect("/catalog/" + categoryUrl + "/" + subcategoryUrl + "/" + goodUrl + "/Discussions")); } else { return(Redirect("/")); } } }
public ActionResult ConfirmOrder(OrderInformation orderInformation) { using (GoodContext db = new GoodContext()) { Order order = new Order { GoodIdArray = string.Join(";", string.Join(";", new List <int>(orderInformation.GoodIdArray).ConvertAll(i => i.ToString()).ToArray())), GoodNameArray = string.Join(";", orderInformation.GoodNameArray), GoodLinkArray = string.Join(";", orderInformation.GoodLinkArray), GoodImageUrlArray = string.Join(";", orderInformation.GoodImageUrlArray), GoodQuantityArray = string.Join(";", new List <int>(orderInformation.GoodQuantityArray).ConvertAll(i => i.ToString()).ToArray()), GoodPriceArray = string.Join(";", string.Join(";", new List <double>(orderInformation.GoodPriceArray).ConvertAll(i => i.ToString()).ToArray())), GoodTotalPriceArray = string.Join(";", new List <double>(orderInformation.GoodTotalPriceArray).ConvertAll(i => i.ToString()).ToArray()), GoodsTotalPrice = orderInformation.GoodsTotalPrice, DeliveryPrice = orderInformation.DeliveryPrice, CustomerName = orderInformation.CustomerName, CardOwnerName = orderInformation.CardOwnerName, CardNumber = orderInformation.CardNumber, CardMonth = orderInformation.CardMonth, CardYear = orderInformation.CardYear, CardCvv = orderInformation.CardCvv, BankSystem = orderInformation.BankSystem, AddresseeFirstName = orderInformation.AddresseeFirstName, AddresseeSecondName = orderInformation.AddresseeSecondName, AddresseeCountry = orderInformation.AddresseeCountry, AddresseeRegion = orderInformation.AddresseeRegion, AddresseeCity = orderInformation.AddresseeCity, AddresseeIndex = orderInformation.AddresseeIndex, AddresseeStreetAddress = orderInformation.AddresseeStreetAddress, AddresseePhoneNumber = orderInformation.AddresseePhoneNumber, AddresseeEmail = orderInformation.AddresseeEmail, DeliveryMethods = orderInformation.DeliveryMethods }; db.Orders.Add(order); db.SaveChanges(); int orderNumber = db.Orders.Max(p => p.Id); SendMail(orderInformation, orderNumber); Session["GoodIdList"] = null; TempData["orderInformation"] = orderInformation; return(Redirect("/cart/order-acceptance")); } }
public ActionResult AddReview(string advantages, string disadvantages, string comment, string experienceOfUse, int mark, string categoryUrl, string subcategoryUrl, string goodUrl, string goodName) { using (GoodContext db = new GoodContext()) { ViewBag.CategoriesData = GetCategoriesData(); if (db.GoodCategories.Where(x => x.CategoryUrl == categoryUrl).Any() && db.GoodSubcategories.Where(x => x.SubcategoryUrl == subcategoryUrl).Any() && db.Goods.Where(x => x.GoodUrl == goodUrl).Any()) { Review newReview = new Review { Reviewer = "asdasd", ReviewerAvatarSrc = "", Date = DateTime.Now.Date.ToUniversalTime(), Advantages = advantages, Disadvantages = disadvantages, Comment = comment, ExperienceOfUse = experienceOfUse, Mark = mark, LikesNumber = 0, DislikesNumber = 0 }; db.Reviews.Add(newReview); List <Good> goodList = db.Goods.Where(x => x.GoodName == goodName).ToList(); foreach (var item in goodList) { Good good = db.Goods.Find(item.Id); good.Reviews.Add(newReview); } db.SaveChanges(); return(Redirect("/catalog/" + categoryUrl + "/" + subcategoryUrl + "/" + goodUrl + "/Reviews")); } else { return(Redirect("/")); } } }