// GET: MachineStatusReport

        public ActionResult DashboardStatus()
        {
            _conn = new ConnectionFactory();
            obj1  = new Dao(_conn);
            obj2  = new Dao1(_conn);
            obj   = new ReportsDao(_conn);
            if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty))
            {
                return(RedirectToAction("Login", "Login", null));
            }
            ViewBag.Logout = Session["Username"];
            ViewBag.roleid = Session["RoleID"];

            //var result = db.tblmachinedetails.Select(m=>m.ShopNo).Distinct();
            ViewData["PlantID"]      = new SelectList(obj2.GetPlantList(), "PlantID", "PlantName");
            ViewData["ShopID"]       = new SelectList(obj2.GetShopList1(), "ShopID", "ShopName");
            ViewData["CellID"]       = new SelectList(obj2.GetCellList(), "CellID", "CellName");
            ViewData["WorkCenterID"] = new SelectList(obj2.GetmachineList1(), "MachineID", "MachineInvNo");
            //ViewData["PlantID"] = new SelectList(db.tblplants.Where(m => m.IsDeleted == 0), "PlantID", "PlantName");
            //ViewData["ShopID"] = new SelectList(db.tblshops.Where(m => m.IsDeleted == 0 && m.PlantID == 999), "ShopID", "ShopName");
            //ViewData["CellID"] = new SelectList(db.tblcells.Where(m => m.IsDeleted == 0 && m.PlantID == 999), "CellID", "CellName");
            //ViewData["WorkCenterID"] = new SelectList(db.tblmachinedetails.Where(m => m.IsDeleted == 0 && m.PlantID == 999), "MachineID", "MachineInvNo");


            return(View());
        }
        public void DeleteReport(int id)
        {
            ReportsDao toDelete = _ctx.Reports.First(r => r.ReportId == id);

            _ctx.Reports.Remove(toDelete);
            _ctx.SaveChanges();
        }
        public Report ReadReport(int id, bool details)
        {
            ReportsDao reportsDao = details ? _ctx.Reports.AsNoTracking().First(i => i.ReportId == id) : _ctx.Reports.First(i => i.ReportId == id);

            ExtensionMethods.CheckForNotFound(reportsDao, "Report", id);

            return(ConvertToDomain(reportsDao));
        }
        public void Update(Report obj)
        {
            ReportsDao newReport   = ConvertToDao(obj);
            ReportsDao foundReport = _ctx.Reports.First(r => r.ReportId == obj.Id);

            if (foundReport != null)
            {
                foundReport.Reason         = newReport.Reason;
                foundReport.ReportApproved = newReport.ReportApproved;
                _ctx.Reports.Update(foundReport);
            }

            _ctx.SaveChanges();
        }
 private Report ConvertToDomain(ReportsDao dao)
 {
     return(new Report()
     {
         Id = dao.ReportId,
         Idea = new Idea {
             Id = dao.IdeaId
         },
         Flagger = new UimvcUser()
         {
             Id = dao.FlaggerId
         },
         Reportee = new UimvcUser()
         {
             Id = dao.ReporteeId
         },
         Reason = dao.Reason,
         Status = (ReportStatus)dao.ReportApproved
     });
 }