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 Filters(AdminFilterModel model) { List<AdminLogModel> logList = new List<AdminLogModel>(); foreach (Log l in new WCFFaultClient().GetLog()) { AdminLogModel logM = new AdminLogModel(); logM.FaultID = l.FaultID; logM.Date = l.Date; logM.FaultDetails = l.Details; logM.Status = new WCFFaultClient().GetStatusByID(l.Status).Status1; Fault f = new WCFFaultClient().GetFault(l.FaultID); if (model.Username!= null) { if (f.Username == model.Username) { logList.Add(logM); } } else if (model.FaultID != null) { if (logM.FaultID==model.FaultID) { logList.Add(logM); } } else if (model.DateFrom != null && model.DateTo != null) { if (logM.Date >= model.DateFrom && logM.Date <= model.DateTo) { logList.Add(logM); } } else { logList.Add(logM); } } return PartialView("_LogManagementFiltered", logList); }
public PartialViewResult ShowProductFaults(Guid orderID, Guid prID) { string faultFilterStartDate = null; string faultFilterEndDate = null; if (Session["filterFaultsStartdate"] != null && Session["filterFaultsEnddate"] != null && Session["filterFaultsStartdate"].ToString() != "" && Session["filterFaultsEnddate"].ToString() != "") { faultFilterStartDate = (string)Session["filterFaultsStartdate"]; faultFilterEndDate = (string)Session["filterFaultsEnddate"]; } Fault f = new WCFFaultClient().GetProductFaultByOrderID(orderID, prID); if (f != null) { List<Log> fLog = new WCFFaultClient().GetLogByFaultID(f.ID).ToList(); List<ClientShowOrderFaultModel> faultLogList = new List<ClientShowOrderFaultModel>(); if (fLog != null) { foreach (Log l in fLog) { ClientShowOrderFaultModel cl = new ClientShowOrderFaultModel(); cl.FaultID = l.FaultID; cl.FaultDetails = l.Details; cl.FaultStatus = new WCFFaultClient().GetStatusByID(l.Status).Status1; cl.Date = l.Date; if (faultFilterStartDate != null && faultFilterEndDate != null) { if (l.Date <= Convert.ToDateTime(faultFilterEndDate) && l.Date >= Convert.ToDateTime(faultFilterStartDate)) { faultLogList.Add(cl); } } else { faultLogList.Add(cl); } } Session["orderIDForPrint"] = orderID; Session["productIDForPrint"] = prID; if (faultLogList.Count > 0) return PartialView("_ShowProductFaults", faultLogList); else { @ViewBag.CartErrorMsg = "No Fault Changes between these Dates"; return PartialView("_CartError"); } } } return PartialView("_DefaultFaultPage"); }
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"); }
public JsonResult UpdateFault(string faultID, string selectedStatusID) { try { Fault sF = new WCFFaultClient().GetFault(new Guid(faultID)); sF.Status = new Guid(selectedStatusID); new WCFFaultClient().UpdateFault(sF); Log l = new Log(); l.ID = Guid.NewGuid(); l.FaultID = sF.ID; l.Details = sF.Details; l.Date = DateTime.Now; l.Status = sF.Status; new WCFFaultClient().AddFaultToLog(l); User user = new WCFUserClient().GetUser(sF.Username); Status s = new WCFFaultClient().GetStatusByID(l.Status); new WCFBAFuncClient().SendEmail(user.Email, "Product Status Change", "Your Product " + sF.ProductID + " Status Has been changed to " + s.Detail); //MSG works commented for testing // SensMsg(user.Mobile, s.Detail, sF.ProductID); return Json("Success"); } catch (Exception) { return Json("Fail"); } }
public PartialViewResult ShowUpdateFault(AdminShowFaultModel model) { try { Fault sF = new WCFFaultClient().GetFault(model.FaultID); sF.Details = model.FaultDetails; sF.Status = new Guid(model.faultEntities.Status.ToString()); new WCFFaultClient().UpdateFault(sF); Log l = new Log(); l.ID = Guid.NewGuid(); l.FaultID = sF.ID; l.Details = sF.Details; l.Date = DateTime.Now; l.Status = sF.Status; new WCFFaultClient().AddFaultToLog(l); User user = new WCFUserClient().GetUser(sF.Username); Status s = new WCFFaultClient().GetStatusByID(l.Status); string imgPath = Server.MapPath("\\Content\\Images\\" + sF.Barcode + ".jpg"); // new WCFBAFuncClient().SendEmail(user.Email, "Product Status Change", "Your Product " + sF.Product.Name + " Status Has been changed to " + s.Status1); new WCFBAFuncClient().SendEmailWithAttachment(user.Email, "Product Status Change", "Your Product " + sF.Product.Name + " Status Has been changed to " + s.Status1, imgPath); string errS = SensMsg(user.Mobile, s.Status1, sF.Product.Name); if (errS == "success") { @ViewBag.faultUpdateStatus = "Fault Was Updated Successfully and user was alerted"; return PartialView("_faultUpdated"); } else { @ViewBag.faultUpdateStatus = "Fault Was Updated Successfully and user was alerted but SMS was not sent"; return PartialView("_faultUpdated"); } } catch (Exception) { @ViewBag.faultUpdateStatus="Fault Was Not Updated"; return PartialView("_faultUpdated"); } }
public PartialViewResult ShowUpdateFault(Guid faultID) { AdminShowFaultModel af = new AdminShowFaultModel(); af.faultEntities = new Fault(); Fault f = new WCFFaultClient().GetFault(faultID); af.FaultID = f.ID; af.ProductName = new ProductServ.WCFProductClient().GetProductByID(f.ProductID).Name; af.StatusList = new SelectList(new WCFFaultClient().GetStatus(), "ID", "Status1"); af.PreviousFault = new WCFFaultClient().GetStatusByID(f.Status).Status1; @ViewBag.fID = faultID; return PartialView("_ShowUpdateFault", af); }