public ActionResult Download(Guid id) { OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.FirstOrDefault(current => current.Id == id); var fileVirtualPath = Server.MapPath("~" + orderDetailInformation.FileUrl); return(File(fileVirtualPath, "application/force-download", Path.GetFileName(fileVirtualPath))); }
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 Edit(OrderDetailInformation orderDetailInformation) { if (ModelState.IsValid) { orderDetailInformation.IsDeleted = false; db.Entry(orderDetailInformation).State = EntityState.Modified; db.SaveChanges(); OrderDetail orderDetail = db.OrderDetails.Include(c => c.Order).FirstOrDefault(c => c.Id == orderDetailInformation.OrderDetailId); if (orderDetail.Order.OrderType == "reportage" || orderDetail.Order.OrderType == "backlink") { return(RedirectToAction("Index", new { id = orderDetailInformation.OrderDetail.OrderId })); } if (orderDetail.Order.OrderType == "package") { return(RedirectToAction("Index", new { id = orderDetailInformation.OrderDetail.OrderId, orderDetailId = orderDetailInformation.OrderDetailId })); } } ViewBag.OrderDetailId = orderDetailInformation.OrderDetailId; ViewBag.OrderId = orderDetailInformation.OrderDetail.OrderId; ViewBag.OrderType = orderDetailInformation.OrderDetail.Order.OrderType; ViewBag.OrderDetailStatusId = new SelectList(db.OrderDetailStatuses, "Id", "Title", orderDetailInformation.OrderDetailStatusId); ViewBag.ProductId = new SelectList(db.Products, "Id", "Title", orderDetailInformation.ProductId); return(View(orderDetailInformation)); }
/// <summary> /// /// </summary> /// <param name="OrderDetails"></param> /// <param name="config"></param> /// <returns></returns> public PricingDetail GetPricingDetails(OrderDetailInformation OrderDetails, NorthwindConfig config) { PricingDetail result; Product product = new Product(); result = product.GetPricingDetails(OrderDetails, config); return(result); }
public ActionResult BacklinkDetails(OrderDetailInfoBacklinkViewModel orderDetailInfo) { OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.Where(current => current.Id == orderDetailInfo.Id && current.IsDeleted == false && current.IsActive) .Include(c => c.OrderDetail).Include(c => c.OrderDetailStatus).FirstOrDefault(); if (ModelState.IsValid) { if (orderDetailInformation != null) { orderDetailInformation.IsDeleted = false; orderDetailInformation.BacklinkKeyword = orderDetailInfo.BacklinkKeyword; orderDetailInformation.BacklinkUrl = orderDetailInfo.BacklinkUrl; orderDetailInformation.OrderDetailStatusId = db.OrderDetailStatuses.FirstOrDefault(c => c.Code == 2).Id; orderDetailInformation.LastModifiedDate = DateTime.Now; db.SaveChanges(); return(Redirect("/order/" + orderDetailInformation.OrderDetail.Order.Code)); } } orderDetailInfo.Menu = menuHelper.ReturnMenu(); orderDetailInfo.FooterLink = menuHelper.GetFooterLink(); if (orderDetailInfo != null) { orderDetailInfo.BacklinkKeyword = orderDetailInfo.BacklinkKeyword; orderDetailInfo.BacklinkUrl = orderDetailInfo.BacklinkUrl; orderDetailInfo.Id = orderDetailInformation.Id; orderDetailInfo.StatusCode = orderDetailInformation.OrderDetailStatus.Code; } OrderDetail orderDetail = db.OrderDetails.FirstOrDefault(current => current.Id == orderDetailInformation.OrderDetailId && current.IsDeleted == false && current.IsActive == true); if (orderDetail != null) { Order order = db.Orders.Find(orderDetail.OrderId); if (order != null) { ViewBag.orderId = order.Code; } ViewBag.Title = "مشخصات بک لینک " + orderDetail.Product.Title; } return(View(orderDetailInfo)); }
public ActionResult DeleteConfirmed(Guid id) { OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.Find(id); orderDetailInformation.IsDeleted = true; orderDetailInformation.DeletionDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: OrderDetailInformations/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.Find(id); if (orderDetailInformation == null) { return(HttpNotFound()); } return(View(orderDetailInformation)); }
public ActionResult Create([Bind(Include = "Id,OrderDetailId,FileUrl,OrderDetailStatusId,ProductId,PublishLink,IsSendPublishSms,IsActive,CreationDate,CreateUserId,LastModifiedDate,IsDeleted,DeletionDate,DeleteUserId,Description")] OrderDetailInformation orderDetailInformation) { if (ModelState.IsValid) { orderDetailInformation.IsDeleted = false; orderDetailInformation.CreationDate = DateTime.Now; orderDetailInformation.Id = Guid.NewGuid(); db.OrderDetailInformations.Add(orderDetailInformation); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrderDetailId = new SelectList(db.OrderDetails, "Id", "FileUrl", orderDetailInformation.OrderDetailId); ViewBag.OrderDetailStatusId = new SelectList(db.OrderDetailStatuses, "Id", "Title", orderDetailInformation.OrderDetailStatusId); ViewBag.ProductId = new SelectList(db.Products, "Id", "Title", orderDetailInformation.ProductId); return(View(orderDetailInformation)); }
// GET: OrderDetailInformations/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.Find(id); if (orderDetailInformation == null) { return(HttpNotFound()); } ViewBag.OrderDetailId = orderDetailInformation.OrderDetailId; ViewBag.OrderId = orderDetailInformation.OrderDetail.OrderId; ViewBag.OrderType = orderDetailInformation.OrderDetail.Order.OrderType; ViewBag.OrderDetailStatusId = new SelectList(db.OrderDetailStatuses, "Id", "Title", orderDetailInformation.OrderDetailStatusId); ViewBag.ProductId = new SelectList(db.Products, "Id", "Title", orderDetailInformation.ProductId); return(View(orderDetailInformation)); }
public string UpdateDb() { List <Order> orders = db.Orders.ToList(); foreach (Order order in orders) { order.OrderType = "reportage"; } db.SaveChanges(); List <OrderDetail> orderDetails = db.OrderDetails.ToList(); foreach (OrderDetail orderDetail in orderDetails) { for (int i = 0; i < orderDetail.Quantity; i++) { OrderDetailInformation odi = new OrderDetailInformation() { Id = Guid.NewGuid(), OrderDetailId = orderDetail.Id, PublishLink = orderDetail.PublishLink, IsSendPublishSms = orderDetail.IsSendPublishSms, CreationDate = DateTime.Now, FileUrl = orderDetail.FileUrl, IsActive = orderDetail.IsActive, IsDeleted = orderDetail.IsDeleted, LastModifiedDate = orderDetail.LastModifiedDate, Description = orderDetail.Description, OrderDetailStatusId = orderDetail.OrderDetailStatusId, DeletionDate = orderDetail.DeletionDate, }; db.OrderDetailInformations.Add(odi); } } db.SaveChanges(); return(String.Empty); }
public ActionResult Upload() { if (Request.Files[0] != null) { var file = Request.Files[0]; Guid orderDetailInfoId = new Guid(Path.GetFileNameWithoutExtension(file.FileName)); OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.Find(orderDetailInfoId); #region Upload and resize image if needed string newFilenameUrl = string.Empty; if (orderDetailInformation != null) { string filename = Path.GetFileName(file.FileName); string newFilename = Guid.NewGuid().ToString().Replace("-", string.Empty) + Path.GetExtension(filename); newFilenameUrl = "/Uploads/reportage/" + newFilename; string physicalFilename = Server.MapPath(newFilenameUrl); file.SaveAs(physicalFilename); orderDetailInformation.FileUrl = newFilenameUrl; orderDetailInformation.OrderDetailStatusId = db.OrderDetailStatuses.FirstOrDefault(current => current.Code == 2).Id; orderDetailInformation.LastModifiedDate = DateTime.Now; db.Entry(orderDetailInformation).State = EntityState.Modified; db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); } #endregion return(Json(false, JsonRequestBehavior.AllowGet)); //var fileName = Path.GetFileName(file.ContentType); //var path = Path.Combine(Server.MapPath("~/Junk/"), fileName); //file.SaveAs(path); //return RedirectToAction("Details"); } return(Json(false, JsonRequestBehavior.AllowGet)); }
public ActionResult SendPublishMessage(string orderDetailInfoId) { try { Guid id = new Guid(orderDetailInfoId); OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.Find(id); if (orderDetailInformation == null) { return(Json("false", JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(orderDetailInformation.PublishLink)) { return(Json("notPublished", JsonRequestBehavior.AllowGet)); } string msg = "کاربر گرامی رپورتاژ شما در وب سایت " + GetReportageNameByProductId(orderDetailInformation) + " منتشر شد. راش وب"; SendSms.SendCommonSms(orderDetailInformation.OrderDetail.Order.User.CellNum, msg); orderDetailInformation.IsSendPublishSms = true; db.SaveChanges(); return(Json("true", JsonRequestBehavior.AllowGet)); } catch { return(Json("false", JsonRequestBehavior.AllowGet)); } }
public ActionResult BacklinkDetails(Guid orderDetailId) { OrderDetailInfoBacklinkViewModel orderDetailInfo = new OrderDetailInfoBacklinkViewModel(); orderDetailInfo.Menu = menuHelper.ReturnMenu(); orderDetailInfo.FooterLink = menuHelper.GetFooterLink(); OrderDetailInformation orderDetailInformation = db.OrderDetailInformations.Where(current => current.OrderDetailId == orderDetailId && current.IsDeleted == false && current.IsActive) .Include(o => o.OrderDetailStatus).FirstOrDefault(); if (orderDetailInformation != null) { orderDetailInfo.BacklinkKeyword = orderDetailInformation.BacklinkKeyword; orderDetailInfo.BacklinkUrl = orderDetailInformation.BacklinkUrl; orderDetailInfo.Id = orderDetailInformation.Id; orderDetailInfo.StatusCode = orderDetailInformation.OrderDetailStatus.Code; } OrderDetail orderDetail = db.OrderDetails.FirstOrDefault(current => current.Id == orderDetailId && current.IsDeleted == false && current.IsActive == true); if (orderDetail != null) { Order order = db.Orders.Find(orderDetail.OrderId); if (order != null) { ViewBag.orderId = order.Code; } ViewBag.Title = "مشخصات بک لینک " + orderDetail.Product.Title; } return(View(orderDetailInfo)); }
public PricingDetail GetPricingDetails(OrderDetailInformation OrderDetails, NorthwindConfig config) { PricingDetail result = new PricingDetail(); string customerID; int productId; List <int> productIds = new List <int>(); int recordCount; if (!OrderDetails.Currency.Equals(config.CurrencyCode, StringComparison.InvariantCultureIgnoreCase)) { result.Result = false; result.ErrorMessage = Resources.ErrorMessages_CurrencyNotSupported; return(result); } if (!OrderDetails.PricingListId.Equals(Constants.DefaultValues.PriceList.ID, StringComparison.InvariantCultureIgnoreCase)) { result.Result = false; result.ErrorMessage = Resources.ErrorMessages_PriceListNotSupported; return(result); } if (OrderDetails.AccountId == null) { result.Result = false; result.ErrorMessage = Resources.ErrorMessages_AccountNotFound; return(result); } customerID = OrderDetails.AccountId; if (!(customerID.StartsWith(Constants.CustomerIdPrefix, StringComparison.InvariantCultureIgnoreCase))) { result.Result = false; result.ErrorMessage = Resources.ErrorMessages_OnlyCustomersSupported; return(result); } customerID = customerID.Substring(Constants.CustomerIdPrefix.Length); DataSet dataSet = new DataSet(); OleDbDataAdapter dataAdapter; string sqlQuery = "Select * from Customers where CustomerID = '" + customerID + "'"; using (OleDbConnection connection = new OleDbConnection(config.ConnectionString)) { dataAdapter = new OleDbDataAdapter(sqlQuery, connection); if (dataAdapter.Fill(dataSet, "Customers") == 0) { result.Result = false; result.ErrorMessage = Resources.ErrorMessages_AccountNotFound; return(result); } } result.Result = true; result.ErrorMessage = ""; result.PricingListId = Constants.DefaultValues.PriceList.ID; DataSets.Product product = new DataSets.Product(); using (OleDbConnection connection = new OleDbConnection(config.ConnectionString)) { DataSets.ProductTableAdapters.ProductsTableAdapter tableAdapter; tableAdapter = new DataSets.ProductTableAdapters.ProductsTableAdapter(); tableAdapter.Connection = connection; recordCount = tableAdapter.Fill(product.Products); } result.PricingDetailLineItems = new PricingDetailLineItem[OrderDetails.LineItemDetails.Length]; DataSets.Product.ProductsRow row; decimal totalPrice = 0; decimal totalLineItemDiscount = 0; result.ErrorMessage = ""; for (int index = 0; index < OrderDetails.LineItemDetails.Length; index++) { result.PricingDetailLineItems[index] = new PricingDetailLineItem(); result.PricingDetailLineItems[index].Description = OrderDetails.LineItemDetails[index].Description; result.PricingDetailLineItems[index].LineItemId = OrderDetails.LineItemDetails[index].LineItemId; result.PricingDetailLineItems[index].LineType = OrderDetails.LineItemDetails[index].LineType; result.PricingDetailLineItems[index].SynchMessage = ""; try { productId = Convert.ToInt32(OrderDetails.LineItemDetails[index].ProductId); } catch (Exception) { result.PricingDetailLineItems[index].SynchMessage = String.Format(Resources.ErrorMessages_ProductIdWrongFormat, OrderDetails.LineItemDetails[index].ProductId.ToString()); result.ErrorMessage += result.PricingDetailLineItems[index].SynchMessage + "\r\n"; result.Result = false; continue; } if (productIds.Contains(productId)) { result.PricingDetailLineItems[index].SynchMessage = String.Format(Resources.ErrorMessages_OrderWithProductTwice, productId); //result.ErrorMessage += result.PricingDetailLineItems[index].SynchMessage + "\r\n"; //result.Result = false; //continue; } productIds.Add(productId); row = product.Products.FindByProductID(productId); if (row == null) { result.PricingDetailLineItems[index].SynchMessage = String.Format(Resources.ErrorMessages_ProductIdNotFound, productId); result.ErrorMessage += result.PricingDetailLineItems[index].SynchMessage + "\r\n"; result.Result = false; continue; } //result.PricingDetailLineItems[index].RepricingStatus = ??; //result.PricingDetailLineItems[index].StockQuantity = row.IsUnitsInStockNull() ? 0 : (int)row.UnitsInStock; result.PricingDetailLineItems[index].ListPrice = row.IsUnitPriceNull() ? (decimal)0 : row.UnitPrice; result.PricingDetailLineItems[index].Tax = 0; //result.PricingDetailLineItems[index].TaxRate = "no Tax"; result.PricingDetailLineItems[index].TaxRate = "0"; result.PricingDetailLineItems[index].DiscountRate = 0; result.PricingDetailLineItems[index].Discount = 0; if (OrderDetails.LineItemDetails[index].Quantity >= 10) { result.PricingDetailLineItems[index].DiscountRate = 10; result.PricingDetailLineItems[index].Discount = 10; } result.PricingDetailLineItems[index].DiscountSum = ((result.PricingDetailLineItems[index].DiscountRate / 100)) * result.PricingDetailLineItems[index].ListPrice; result.PricingDetailLineItems[index].QuotedPrice = result.PricingDetailLineItems[index].ListPrice * (1 - (result.PricingDetailLineItems[index].DiscountRate / 100)); result.PricingDetailLineItems[index].QuotedPriceTotal = OrderDetails.LineItemDetails[index].Quantity * result.PricingDetailLineItems[index].QuotedPrice; totalPrice += result.PricingDetailLineItems[index].QuotedPriceTotal; totalLineItemDiscount += OrderDetails.LineItemDetails[index].Quantity * result.PricingDetailLineItems[index].DiscountSum; } result.DiscountAmt = 0; result.DiscountPC = 0; result.DiscountType = ""; result.GrossAmt = totalPrice; result.LineItemDisc = totalLineItemDiscount; result.NetAmt = totalPrice; //result.NoDiscAmt = 0; //???? result.PricingListId = OrderDetails.PricingListId; result.OrderQuoteId = OrderDetails.OrderQuoteId; //result.Reference = ""; result.Tax = 0; return(result); }
public void InsertOrderDetailInfo(Order order) { List <OrderDetail> orderDetails = db.OrderDetails.Where(c => c.OrderId == order.Id).ToList(); foreach (OrderDetail orderDetail in orderDetails) { if (order.OrderType == "package") { ReportageGroup reportageGroup = db.ReportageGroups .FirstOrDefault(c => c.ProductId == orderDetail.ProductId); List <Reportage> reportages = db.Reportages.Where(c => c.ReportageGroupId == reportageGroup.Id && c.IsActive && c.IsDeleted == false).ToList(); for (int i = 0; i < orderDetail.Quantity; i++) { foreach (Reportage reportage in reportages) { OrderDetailInformation orderDetailInformation = new OrderDetailInformation() { Id = Guid.NewGuid(), OrderDetailId = orderDetail.Id, OrderDetailStatusId = db.OrderDetailStatuses.FirstOrDefault(current => current.Code == 1).Id, CreationDate = DateTime.Now, IsDeleted = false, IsActive = true, ProductId = reportage.ProductId }; db.OrderDetailInformations.Add(orderDetailInformation); } } } else if (order.OrderType == "reportage") { for (int i = 0; i < orderDetail.Quantity; i++) { OrderDetailInformation orderDetailInformation = new OrderDetailInformation() { Id = Guid.NewGuid(), OrderDetailId = orderDetail.Id, OrderDetailStatusId = db.OrderDetailStatuses.FirstOrDefault(current => current.Code == 1).Id, CreationDate = DateTime.Now, IsDeleted = false, IsActive = true, }; db.OrderDetailInformations.Add(orderDetailInformation); } } else if (order.OrderType == "backlink") { for (int i = 0; i < orderDetail.Quantity; i++) { OrderDetailInformation orderDetailInformation = new OrderDetailInformation() { Id = Guid.NewGuid(), OrderDetailId = orderDetail.Id, OrderDetailStatusId = db.OrderDetailStatuses.FirstOrDefault(current => current.Code == 1).Id, CreationDate = DateTime.Now, IsDeleted = false, IsActive = true, }; db.OrderDetailInformations.Add(orderDetailInformation); } } } }