public string GetReportageNameByProductId(OrderDetailInformation orderDetailInformation) { if (orderDetailInformation.OrderDetail.Order.OrderType == "reportage") { Reportage reportage = db.Reportages.FirstOrDefault(c => c.ProductId == orderDetailInformation.OrderDetail.ProductId); if (reportage == null) { return(string.Empty); } return(reportage.FullName); } else if (orderDetailInformation.OrderDetail.Order.OrderType == "package") { Reportage reportage = db.Reportages.FirstOrDefault(c => c.ProductId == orderDetailInformation.ProductId); if (reportage == null) { return(string.Empty); } return(reportage.FullName); } return(string.Empty); }
public ActionResult DeleteConfirmed(Guid id) { Reportage reportage = db.Reportages.Find(id); reportage.IsDeleted = true; reportage.DeletionDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index", new { id = reportage.ReportageGroupId })); }
public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Reportage reportage = db.Reportages.Find(id); if (reportage == null) { return(HttpNotFound()); } ViewBag.id = reportage.ReportageGroupId; return(View(reportage)); }
public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Reportage reportage = db.Reportages.Find(id); if (reportage == null) { return(HttpNotFound()); } ViewBag.id = reportage.ReportageGroupId; ViewBag.ReportageGroupId = new SelectList(db.ReportageGroups.Where(current => current.IsDeleted == false).ToList(), "Id", "Title", reportage.ReportageGroupId); return(View(reportage)); }
public ActionResult Create(Reportage reportage, Guid id, HttpPostedFileBase fileUpload) { if (ModelState.IsValid) { #region Upload and resize image if needed string newFilenameUrl = string.Empty; if (fileUpload != null) { string filename = Path.GetFileName(fileUpload.FileName); string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty) + Path.GetExtension(filename); newFilenameUrl = "/Uploads/reportage/" + newFilename; string physicalFilename = Server.MapPath(newFilenameUrl); fileUpload.SaveAs(physicalFilename); reportage.ImageUrl = newFilenameUrl; } #endregion Product product = new Product() { Id = Guid.NewGuid(), IsDeleted = false, IsActive = reportage.IsActive, CreationDate = DateTime.Now, Title = reportage.FullName, ProductTypeId = db.ProductTypes.FirstOrDefault(c => c.Name == "reportage").Id }; db.Products.Add(product); reportage.ProductId = product.Id; reportage.IsDeleted = false; reportage.CreationDate = DateTime.Now; reportage.Id = Guid.NewGuid(); reportage.ReportageGroupId = id; db.Reportages.Add(reportage); db.SaveChanges(); return(RedirectToAction("Index", new { id = id })); } ViewBag.id = id; return(View(reportage)); }
public decimal GetBuyAmountByProduct(Product product) { decimal amount = 0; if (product.ProductType.Name == "reportage") { Reportage reportage = db.Reportages.FirstOrDefault(c => c.ProductId == product.Id); if (reportage.BuyAmount != null) { amount = reportage.BuyAmount.Value; } return(amount); } return(amount); }
public ActionResult Edit(Reportage reportage, HttpPostedFileBase fileUpload) { if (ModelState.IsValid) { #region Upload and resize image if needed string newFilenameUrl = string.Empty; if (fileUpload != null) { string filename = Path.GetFileName(fileUpload.FileName); string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty) + Path.GetExtension(filename); newFilenameUrl = "/Uploads/reportage/" + newFilename; string physicalFilename = Server.MapPath(newFilenameUrl); fileUpload.SaveAs(physicalFilename); reportage.ImageUrl = newFilenameUrl; } #endregion Product product = db.Products.Find(reportage.ProductId); if (product != null) { product.Title = reportage.FullName; product.IsActive = reportage.IsActive; } reportage.IsDeleted = false; reportage.LastModifiedDate = DateTime.Now; db.Entry(reportage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = reportage.ReportageGroupId })); } ViewBag.id = reportage.ReportageGroupId; ViewBag.ReportageGroupId = new SelectList(db.ReportageGroups.Where(current => current.IsDeleted == false && current.IsActive == true).ToList(), "Id", "Title", reportage.ReportageGroupId); return(View(reportage)); }
public decimal GetAmountByProductForInsertOrderDetail(Product product) { decimal amount = 0; if (product.ProductType.Name == "reportage") { Reportage reportage = db.Reportages.FirstOrDefault(c => c.ProductId == product.Id); amount = reportage.Price; if (reportage.IsInPromotion) { if (reportage.DiscountAmount != null) { amount = reportage.DiscountAmount.Value; } } return(amount); } else if (product.ProductType.Name == "backlink") { BackLinkDetail backLinkDetail = db.BackLinkDetails.FirstOrDefault(c => c.ProductId == product.Id); if (backLinkDetail != null) { amount = backLinkDetail.Amount; } else { amount = 0; } return(amount); } else if (product.ProductType.Name == "package") { ReportageGroup reportageGroup = db.ReportageGroups.FirstOrDefault(c => c.ProductId == product.Id); if (reportageGroup != null) { if (reportageGroup.Price != null) { amount = reportageGroup.Price.Value; } else { amount = 0; } } else { amount = 0; } return(amount); } return(amount); }