public ActionResult GetLotsForRawMaterial(int rawMaterialId)
        {
            var lots   = RawMaterialReceivedRepo.GetAll(1, rawMaterialId);
            var retVal = Json(lots);

            return(retVal);
        }
        private ActionResult ShowEditView(CurrentRawMaterialViewModel vm)
        {
            var lines = ProductionLineRepo.GetProductionLines(vm.PlantId);

            ViewBag.LineID = new SelectList(lines, "Code", "Code");

            var rawMaterialCodes = RawMaterialReceivedRepo.GetAvailableRawMaterialIds(vm.PlantId);

            ViewBag.RawMaterialReceivedCode = new SelectList(rawMaterialCodes, vm.RawMaterialReceivedCode);

            var lots = RawMaterialReceivedRepo.GetAll(vm.PlantId, (int)(vm.RawMaterialReceivedId ?? 0));

            ViewBag.Lots = new SelectList(lots, "ID", "LotID", vm.RawMaterialReceivedId);

            return(View(vm));
        }
        // GET: /RawMaterialCurrent/Create
        public ActionResult Create(int plantId)
        {
            var model = new CurrentRawMaterialViewModel
            {
                PlantId      = plantId,
                LastModified = DateTime.Now,
                DateEntered  = DateTime.Now,
                ModifiedBy   = CurrentUser,
                EnteredBy    = CurrentUser
            };

            // MOCK DATA - PRODUCTION LINES
            var lines = ProductionLineRepo.GetProductionLines(plantId);

            ViewBag.LineID = new SelectList(lines, "Code", "Code");


            var rawMaterialCodes = RawMaterialReceivedRepo.GetAvailableRawMaterialIds(plantId);

            ViewBag.RawMaterialReceivedCode = new SelectList(rawMaterialCodes);


            return(View(model));
        }
        //
        // GET: /RawMaterialQC/
        public ActionResult Index(int?id, bool unlocked = false)
        {
            TPOMVCApplicationEntities db = new TPOMVCApplicationEntities();
            //
            var RawMat = db.RawMaterialQCs.Where(s => s.RawMaterialReceivedID != null).ToList();

            TPO.BL.RawMaterials.RawMaterial RawMatList = new TPO.BL.RawMaterials.RawMaterial();
            ViewBag.RawMaterialQCList = RawMatList.GetRawMaterials();

            //TODO: Refactor after RawMaterialModel is completed to use intID
            List <RawMaterialModel> rawMatListFromBL = RawMatList.GetRawMaterials();
            var QCList = db.Users.Where(s => s.ID != null).ToList();


            IEnumerable <SelectListItem> rawMaterialSelectList = from s in rawMatListFromBL
                                                                 select new SelectListItem
            {
                Value = s.RawMaterialCode,
                Text  = (s.RawMaterialCode + " | " + s.RawMaterialName)
            };
            //IEnumerable<SelectListItem> selectList = from s in RawMat
            //                                         select new SelectListItem
            //                                         {
            //                                             Value = s.RawMaterialID,
            //                                             Text = s.RawMaterialID + " | " + s.RawMaterialLotID.ToString()
            //                                         };

            IEnumerable <SelectListItem> lotSelectList = from s in RawMaterialReceivedRepo.GetAll()
                                                         select new SelectListItem
            {
                Value = s.LotNumber,
                Text  = s.LotNumber + " | " + s.LastModified.ToShortDateString()
            };


            //IEnumerable<SelectListItem> lotSelectList = from s in RawMat
            //                                            select new SelectListItem
            //                                            {
            //                                                Value = s.RawMaterialLotID,
            //                                                Text = (s.RawMaterialLotID.Length != 11 ? s.RawMaterialLotID : s.RawMaterialLotID) + " | " +
            //                                                s.DateEntered.ToShortDateString() +
            //                                                " | " + s.LastModified.ToShortDateString()
            //                                            };

            IEnumerable <SelectListItem> lotTestList = from s in RawMat
                                                       select new SelectListItem
            {
                Value = s.ID.ToString(),
                Text  = s.DateEntered.ToShortDateString() + " | " + s.BoxCarTested
            };


            //new SelectList()
            ViewBag.RawMaterialQC             = new SelectList(rawMaterialSelectList, "Value", "Text");
            ViewBag.RawMaterialLotQC          = new SelectList(lotSelectList, "Value", "Text");
            ViewBag.RawMaterialQCLotTest      = new SelectList(lotTestList, "Value", "Text");
            ViewBag.RawMaterialQCLastModified = new SelectList(RawMat, "ID", "LastModified");
            ViewBag.RawMaterialEnteredBy      = new SelectList(QCList, "ID", "FullName");

            TPO.BL.RawMaterials.RawMaterialQC qcBL = new TPO.BL.RawMaterials.RawMaterialQC();

            //if (id != null)
            //{
            //    RawMaterialQCModel model = qcBL.GetRawMaterialQCModelByRawMaterialQCID(id ?? Convert.ToInt32(id));
            //}
            //else
            //{
            //    RawMaterialQCModel model = new RawMaterialQCModel();
            //}

            RawMaterialQCModel model = qcBL.GetRawMaterialQCModelByRawMaterialQCID(id ?? Convert.ToInt32(id));

            if (model == null)
            {
                model = new RawMaterialQCModel();
            }

            var tests = (from t in db.RawMaterialQCs
                         where t.RawMaterialReceived.ID == t.RawMaterialReceivedID
                         select t).ToList();

            ViewBag.QCItems = tests;

            return(View(model));
        }