public PartialViewResult Faults() { WCFProductClient pClient = new WCFProductClient(); WCFCart_OrderClient oClient = new WCFCart_OrderClient(); List<Order> orders = oClient.GetOrders(@User.Identity.Name).ToList(); List<OrderProductModel> orderProductsList = new List<OrderProductModel>(); foreach (Order order in orders) { List<Order_Product> orderProducts = oClient.GetOrderProducts(order.ID).ToList(); foreach (Order_Product op in orderProducts) { Product aP = pClient.GetProductByID(op.ProductID); OrderProductModel opM = new OrderProductModel(); opM.ProductID = aP.ID; opM.ProductName = aP.Name; opM.Features = aP.Features; opM.QtyPurchased = op.Quantity; opM.DatePurchased = order.DateOrdered; opM.ExpiryDate = order.DateOrdered.AddYears(2); opM.Status = "Not Available"; if (opM.ExpiryDate > DateTime.Today) { orderProductsList.Add(opM); } } } return PartialView("_ShowFaults",orderProductsList); }
public ActionResult FaultManagement() { WCFProductClient pClient = new WCFProductClient(); List<AdminFaultModel> aFList = new List<AdminFaultModel>(); List<Fault> fList = new WCFFaultClient().GetAllFaults().ToList(); foreach (Fault f in fList) { AdminFaultModel aF = new AdminFaultModel(); aF.ID = f.ID; aF.Username = f.Username; aF.ProductID = f.ProductID; aF.SelectedStatusName = new WCFFaultClient().GetStatusByID(f.Status).Status1; // aF.StatusList = new SelectList(new WCFFaultClient().GetStatus(), "ID", "Status1"); //change to status aF.ProductName = pClient.GetProductByID(f.ProductID).Name; aF.FaultDetails = f.Details; aFList.Add(aF); } return View("_FaultManagement",aFList); }
public PartialViewResult ShowOrderDetails(Guid id) { WCFProductClient pClient = new WCFProductClient(); WCFCart_OrderClient oClient = new WCFCart_OrderClient(); @ViewBag.orderID = id; Order cOrder = oClient.GetOrder(id); List<OrderProductModel> orderProductsList = new List<OrderProductModel>(); List<Order_Product> orderProducts = oClient.GetOrderProducts(id).ToList(); foreach (Order_Product op in orderProducts) { Product aP = pClient.GetProductByID(op.ProductID); OrderProductModel opM = new OrderProductModel(); opM.ProductID = aP.ID; opM.ProductName = aP.Name; opM.Features = aP.Features; opM.QtyPurchased = op.Quantity; opM.DatePurchased = cOrder.DateOrdered; opM.ExpiryDate = cOrder.DateOrdered.AddYears(2); Fault f = new WCFFaultClient().GetProductFaultByOrderID(id, aP.ID); if (f != null) { opM.Status = new WCFFaultClient().GetStatusByID(f.Status).Status1; } else { opM.Status = "No Faults Reported"; } Rating r = new WCFProductClient().GetRating(aP.ID, @User.Identity.Name); if (r != null) { opM.Rating = r.Rating1; } else { opM.Rating = 0; } orderProductsList.Add(opM); } return PartialView("_ShowOrderDetails", orderProductsList); }
//---------------------------------------Printing--------------------------------------------------- public FileResult PrintProductFaults() { Guid orderID =(Guid)Session["orderIDForPrint"]; Guid prID = (Guid)Session["productIDForPrint"]; Order order = new WCFCart_OrderClient().GetOrder(orderID); Order_Product op = new WCFCart_OrderClient().GetOrderProduct(orderID,prID); Fault fault = new WCFFaultClient().GetProductFaultByOrderID(orderID, prID); Product p = new WCFProductClient().GetProductByID(prID); List<Log> logs = new WCFFaultClient().GetLogByFaultID(fault.ID).ToList(); ; decimal totalAmount = p.Price * op.Quantity; // Create a Document object var document = new Document(PageSize.A4, 50, 50, 25, 25); // Create a new PdfWriter object, specifying the output stream var output = new FileStream("C:\\Users\\Kappuna\\Documents\\GitHub\\DSAAssignment1Sit1\\MVCAssignment - Copy\\MVCAssignment\\Content\\TempReports\\" + fault.Barcode + "Report.pdf", FileMode.Create); var writer = PdfWriter.GetInstance(document, output); // Open the Document for writing document.Open(); var titleFont = FontFactory.GetFont("Arial", 18, Font.BOLD); var subTitleFont = FontFactory.GetFont("Arial", 14, Font.BOLD); var boldTableFont = FontFactory.GetFont("Arial", 12, Font.BOLD); var endingMessageFont = FontFactory.GetFont("Arial", 10, Font.ITALIC); var bodyFont = FontFactory.GetFont("Arial", 12, Font.NORMAL); document.Add(new Paragraph("Electros LTD", titleFont)); document.Add(new Paragraph("Item:", subTitleFont)); var orderInfoTable = new PdfPTable(5); orderInfoTable.HorizontalAlignment = 0; orderInfoTable.SpacingBefore = 10; orderInfoTable.SpacingAfter = 10; orderInfoTable.DefaultCell.Border = 0; orderInfoTable.SetWidths(new int[] { 3, 4,4,4,4}); orderInfoTable.AddCell("Item No."); orderInfoTable.AddCell("Item:"); orderInfoTable.AddCell("Amount Purchased"); orderInfoTable.AddCell("Date Purchased"); orderInfoTable.AddCell("Warranty Expiry Date"); string id = p.ID.ToString(); id = id.Substring(0, 8); orderInfoTable.AddCell(string.Format("{0}", id)); orderInfoTable.AddCell(string.Format("{0}", p.Name)); orderInfoTable.AddCell(string.Format("{0}", totalAmount)); orderInfoTable.AddCell(string.Format("{0}", order.DateOrdered)); orderInfoTable.AddCell(string.Format("{0}", order.DateOrdered.AddYears(2))); document.Add(orderInfoTable); document.Add(new Paragraph("Fault:",subTitleFont)); var faultInfoTable = new PdfPTable(3); faultInfoTable.HorizontalAlignment = 0; faultInfoTable.SpacingBefore = 10; faultInfoTable.SpacingAfter = 10; faultInfoTable.DefaultCell.Border = 4; faultInfoTable.SetWidths(new int[] { 4, 4, 4 }); //Fault Table faultInfoTable.AddCell("Fault Details"); faultInfoTable.AddCell("Status"); faultInfoTable.AddCell("Date Changed"); foreach (Log l in logs) { faultInfoTable.AddCell(string.Format("{0}",l.Details)); faultInfoTable.AddCell(string.Format("{0}", new WCFFault().GetStatusByID(l.Status).Status1)); faultInfoTable.AddCell(string.Format("{0}", l.Date)); } document.Add(faultInfoTable); // Close the Document - this saves the document contents to the output stream document.Close(); string atch = Server.MapPath("\\Content\\TempReports\\" + fault.Barcode + "Report.pdf"); User user = new WCFUserClient().GetUser(@User.Identity.Name); new WCFBAFuncClient().SendEmailWithAttachment(user.Email, "Product Receipt", "Reciept for the faults of Product " + p.Name + "\nThanks For Using Electros Ltd", atch); return File("/Content/TempReports/"+fault.Barcode+"Report.pdf", "application/pdf"); }
//need to fix view and status public PartialViewResult ShowOrderDetails(Guid id) { WCFProductClient pClient = new WCFProductClient(); WCFCart_OrderClient oClient = new WCFCart_OrderClient(); Order cOrder = oClient.GetOrder(id); List<OrderProductModel> orderProductsList = new List<OrderProductModel>(); List<Order_Product> orderProducts = oClient.GetOrderProducts(id).ToList(); foreach (Order_Product op in orderProducts) { Product aP = pClient.GetProductByID(op.ProductID); OrderProductModel opM = new OrderProductModel(); opM.ProductID = aP.ID; opM.ProductName = aP.Name; opM.Features = aP.Features; opM.QtyPurchased = op.Quantity; opM.DatePurchased = cOrder.DateOrdered; opM.ExpiryDate = cOrder.DateOrdered.AddYears(2); opM.Status = "Not Available"; orderProductsList.Add(opM); } return PartialView("_ShowOrderDetails", orderProductsList); }