public ConsolidatedCurrentRawMaterialsAndRollsViewModel ConsolidatedCurrentRawMaterialsAndRollsViewModel_Get(string lineID)
        {
            ScrimType             scrimTypeBL = new ScrimType();
            List <ScrimTypeModel> scrimTypes  = scrimTypeBL.GetScrimTypeModels();

            scrimTypes.Insert(0, new ScrimTypeModel()
            {
                Code = "N/A"
            });
            GetRollTypesList();
            ViewBag.ScrimRoll = new SelectList(new List <TPO.Model.Scrim.TPOCurrentScrimModel>());
            ProductionLine prodLineBL = new ProductionLine();

            List <TPO.Model.Production.ProductionLineModel> lines = prodLineBL.GetProductionLines();

            //lines.Insert(0, new TPO.Model.Production.ProductionLineModel() { Code = "Select Line" });
            ViewBag.ProductionLine = new SelectList(lines, "Code", "Code");
            //ViewBag.productionLineSelectList = new SelectList(lines, "Code", "Code");
            TPOCurrentScrim bl = new TPOCurrentScrim();

            ConsolidatedCurrentRawMaterialsAndRollsViewModel model = new ConsolidatedCurrentRawMaterialsAndRollsViewModel();

            TPOCurrentScrimModel tpoCurrentModel = bl.GetTPOCurrentScrimModelByLineID(lineID);

            if (tpoCurrentModel == null)
            {
                tpoCurrentModel       = new TPOCurrentScrimModel();
                model.TPOCurrentScrim = tpoCurrentModel;
            }
            else
            {
                model.TPOCurrentScrim = tpoCurrentModel;
            }

            List <CurrentRawMaterialDTO>       currentDTOList = GetRawMaterailListing(lineID);
            List <CurrentRawMaterialViewModel> model2         = currentDTOList.Select(MapCurrentRawMaterialDTOToViewModel).ToList();

            if (!model2.Any())
            {
                model2 = new List <CurrentRawMaterialViewModel>();
                model.CurrentRawMaterialList = model2;
            }
            else
            {
                model.CurrentRawMaterialList = model2;
            }

            if (!model.CurrentRawMaterialList.Any() && model.TPOCurrentScrim.LineID == null)
            {
                model.CurrentRawMaterial        = new CurrentRawMaterialViewModel();
                model.CurrentRawMaterial.LineId = "1";
                model.TPOCurrentScrim.LineID    = "1";
            }
            else
            {
                model.CurrentRawMaterialList = model2;
            }

            return(model);
        }
        private static TPO.DL.Models.TPOCurrentScrim Bind(TPOCurrentScrimModel model, TPO.DL.Models.TPOCurrentScrim to)
        {
            //to.PlantID = model.PlantID;
            //TODO:  Implement retrieving PlantID
            to.PlantID = 1;
            to.LineID  = model.LineID;
            if (model.Scrim1RollID != TPOCurrentScrimModel.INVALID_ID)
            {
                to.Scrim1RollID = model.Scrim1RollID;
            }
            else
            {
                to.Scrim1RollID = null;
            }
            if (model.Scrim1TypeID != TPOCurrentScrimModel.INVALID_ID)
            {
                to.Scrim1TypeID = model.Scrim1TypeID;
            }
            else
            {
                to.Scrim1TypeID = null;
            }
            if (model.Scrim2RollID != TPOCurrentScrimModel.INVALID_ID)
            {
                to.Scrim2RollID = model.Scrim2RollID;
            }
            else
            {
                to.Scrim2RollID = null;
            }
            if (model.Scrim2TypeID != TPOCurrentScrimModel.INVALID_ID)
            {
                to.Scrim2TypeID = model.Scrim2TypeID;
            }
            else
            {
                to.Scrim2TypeID = null;
            }
            if (model.FleeceRollID != TPOCurrentScrimModel.INVALID_ID)
            {
                to.FleeceRollID = model.FleeceRollID;
            }
            else
            {
                to.FleeceRollID = null;
            }
            if (model.FleeceTypeID != TPOCurrentScrimModel.INVALID_ID)
            {
                to.FleeceTypeID = model.FleeceTypeID;
            }
            else
            {
                to.FleeceTypeID = null;
            }

            //to.ScrimPos = model.ScrimPos;
            to.ScrimPos = " ";
            return(to);
        }
        public ActionResult Create(TPOCurrentScrimModel model)
        {
            TPOCurrentScrim bl = new TPOCurrentScrim();

            model = bl.InsertTPOCurrentScrimModel(model);
            TempData["ActionMessage"]     = MessageRepository.GetStringValue(MessageKeys.ResponseMessageSuccessSave);
            TempData["ActionMessageType"] = MessageRepository.GetStringValue(MessageKeys.ResponseTypeSuccess);
            return(RedirectToAction("Edit", model.ID));
        }
 public void UpdateTPOCurrentScrimModel(TPOCurrentScrimModel model)
 {
     using (ScrimRepository repo = new ScrimRepository())
     {
         TPO.DL.Models.TPOCurrentScrim entity = repo.GetTPOCurrentScrimByID(model.ID);
         if (entity != null)
         {
             entity              = Bind(model, entity);
             entity.ModifiedBy   = "ETG QA";
             entity.LastModified = DateTime.Now;
             repo.SaveChanges();
         }
     }
 }
        public TPOCurrentScrimModel GetTPOCurrentScrimModelByLineID(string lineID)
        {
            TPOCurrentScrimModel model = null;

            using (ScrimRepository repo = new ScrimRepository())
            {
                TPO.DL.Models.TPOCurrentScrim entity = repo.GetTPOCurrentScrimByLineID(lineID);
                if (entity != null)
                {
                    model = Bind(entity, new TPOCurrentScrimModel());
                }
            }
            return(model);
        }
        public TPOCurrentScrimModel InsertTPOCurrentScrimModel(TPOCurrentScrimModel model)
        {
            TPOCurrentScrimModel returnModel = null;

            using (ScrimRepository repo = new ScrimRepository())
            {
                TPO.DL.Models.TPOCurrentScrim entity = Bind(model, new TPO.DL.Models.TPOCurrentScrim());
                entity.EnteredBy    = "ETG QA";
                entity.DateEntered  = DateTime.Now;
                entity.ModifiedBy   = "ETG QA";
                entity.LastModified = DateTime.Now;
                repo.InsertTPOCurrentScrim(entity);
                returnModel = Bind(entity, new TPOCurrentScrimModel());
            }
            return(returnModel);
        }
        //
        // GET: /CurrentScrim/Create
        public ActionResult Create()
        {
            ScrimType             scrimTypeBL = new ScrimType();
            List <ScrimTypeModel> scrimTypes  = scrimTypeBL.GetScrimTypeModels();

            scrimTypes.Insert(0, new ScrimTypeModel()
            {
                Code = "N/A"
            });
            GetRollTypesList();
            ViewBag.ScrimRoll = new SelectList(new List <TPO.Model.Scrim.TPOCurrentScrimModel>());
            ProductionLine prodLineBL = new ProductionLine();

            ViewBag.ProductionLine = new SelectList(prodLineBL.GetProductionLines(), "Code", "Code");
            TPOCurrentScrimModel model = new TPOCurrentScrimModel();

            return(View(model));
        }
示例#8
0
        public JsonResult SaveCurrentScrimResult(TPOCurrentScrimModel model)
        {
            ResponseMessage responseMessage;

            try
            {
                var dto = Mapper.Map <TPOCurrentScrimModel, TPOCurrentScrimDto>(model);
                dto.PlantID      = CurrentPlantId;
                dto.ModifiedBy   = CurrentUser;
                dto.LastModified = DateTime.Now;
                using (TPOCurrentScrimService svc = new TPOCurrentScrimService())
                {
                    if (dto.ID > 0)
                    {
                        svc.Update(dto);
                    }
                    else
                    {
                        dto.DateEntered = dto.LastModified;
                        dto.EnteredBy   = CurrentUser;
                        dto.PlantID     = CurrentPlantId;
                        dto.ID          = svc.Add(dto);
                    }
                }
                model = Mapper.Map <TPOCurrentScrimDto, TPOCurrentScrimModel>(dto);
                //Have to set these manually
                //AutoMapper is setting them to null every time
                model.DateEntered  = dto.DateEntered;
                model.EnteredBy    = dto.EnteredBy;
                model.LastModified = dto.LastModified;
                model.ModifiedBy   = dto.ModifiedBy;

                responseMessage = SetResponseMesssage(ActionTypeMessage.SuccessfulSave);
            }
            catch (Exception exc)
            {
                responseMessage = SetResponseMesssage(ActionTypeMessage.FailedSave, exc.Message);
            }

            return(Json(responseMessage, JsonRequestBehavior.AllowGet));
        }
示例#9
0
        public JsonResult CurrentScrimByLineResult(int lineID = 0)
        {
            TPOCurrentScrimModel model = new TPOCurrentScrimModel();

            using (TPOCurrentScrimService svc = new TPOCurrentScrimService())
            {
                var dto = svc.GetByLineID(lineID).FirstOrDefault();
                if (dto == null)
                {
                    dto = new TPOCurrentScrimDto();
                }
                Mapper.Map <TPOCurrentScrimDto, TPOCurrentScrimModel>(dto, model);
                //Have to set these manually
                //AutoMapper is setting them to null every time
                model.DateEntered  = dto.DateEntered;
                model.EnteredBy    = dto.EnteredBy;
                model.LastModified = dto.LastModified;
                model.ModifiedBy   = dto.ModifiedBy;
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
 private static TPOCurrentScrimModel Bind(TPO.DL.Models.TPOCurrentScrim entity, TPOCurrentScrimModel to)
 {
     to.ID           = entity.ID;
     to.PlantID      = entity.PlantID;
     to.Scrim1RollID = entity.Scrim1RollID.HasValue ? entity.Scrim1RollID.Value : TPOCurrentScrimModel.INVALID_ID;
     to.Scrim1TypeID = entity.Scrim1TypeID.HasValue ? entity.Scrim1TypeID.Value : TPOCurrentScrimModel.INVALID_ID;
     to.Scrim2RollID = entity.Scrim2RollID.HasValue ? entity.Scrim2RollID.Value : TPOCurrentScrimModel.INVALID_ID;
     to.Scrim2TypeID = entity.Scrim2TypeID.HasValue ? entity.Scrim2TypeID.Value : TPOCurrentScrimModel.INVALID_ID;
     to.FleeceRollID = entity.FleeceRollID.HasValue ? entity.FleeceRollID.Value : TPOCurrentScrimModel.INVALID_ID;
     to.FleeceTypeID = entity.FleeceTypeID.HasValue ? entity.FleeceTypeID.Value : TPOCurrentScrimModel.INVALID_ID;
     to.ScrimPos     = entity.ScrimPos;
     to.LineID       = entity.LineID;
     to.DateEntered  = entity.DateEntered;
     to.EnteredBy    = entity.EnteredBy;
     to.LastModified = entity.LastModified;
     to.ModifiedBy   = entity.ModifiedBy;
     return(to);
 }