public ActionResult AddFault()
        {
            string code = new WCFBAFuncClient().GenerateRandomTicket(6);
            BarCode b = new BarCode();
            MemoryStream ms = new MemoryStream(b.Code39(code, 100, false, code));

            var img = System.Drawing.Image.FromStream(ms);
            img.Save("C:\\Users\\Kappuna\\Documents\\GitHub\\DSAAssignment\\MVCAssignment - Copy\\MVCAssignment\\Content\\Images\\" + code + ".jpg");

            return View();
        }
        public ActionResult FaultLogIn(LogInModel model, string returnUrl)
        {
            //Get  6 Digit Ticket
               string code = new WCFBAFuncClient().GenerateRandomTicket(6);

               //Check if ticket is filled
               if (code != null)
               {
               if (ModelState.IsValid)
               {
                   //Authorise the user
                   //call the service to check the username and password
                   bool validateUser = new UserServ.WCFUserClient().LogIn(model.Username, model.PasswordToken);

                   if (validateUser)
                   {
                       FormsAuthentication.SetAuthCookie(model.Username, true);
                       BarCode b = new BarCode();
                       MemoryStream ms = new MemoryStream(b.Code39(code, 100, false, code));

                       var img = System.Drawing.Image.FromStream(ms);
                       string imgPath = Server.MapPath("\\Content\\Images\\" + code + ".jpg");

                       img.Save(imgPath);

                       FaultModel fm = new FaultModel();
                       fm.BarCodeImg = "..\\Content\\Images\\" + code + ".jpg";
                       fm.Code = Convert.ToInt32(code);

                       return RedirectToAction("FaultDetails", new { barcodeImg = fm.BarCodeImg, code=fm.Code });
                       //return PartialView("_FaultDetails", fm);
                   }
                   else
                   {
                       ModelState.AddModelError("", "The user name or password provided is incorrect.");
                       return PartialView("_FaultLogIn", model);
                   }
               }
               else
               {
                   ModelState.AddModelError("", "The user name or password provided is incorrect.");
                   return PartialView("_FaultLogIn", model);
               }
               }
               else
               {
               return PartialView("_FaultLogIn",model);
               }
        }
        public PartialViewResult TopRatedProduct()
        {
            Product p = new WCFBAFuncClient().GetHighestRatingProduct();

            List<TopRatedProductModel> tpl = new List<TopRatedProductModel>();

            TopRatedProductModel tp = new TopRatedProductModel();
            tp.Name = p.Name;
            tp.Rating = new WCFProductClient().GetProductAverageRating(p.ID);
            tp.Features = p.Features;
            tp.Img = p.Image;
            tpl.Add(tp);

            return PartialView("_TopRatedProduct",tpl);
        }