private ScrimType Save(ScrimTypeDto dto)
        {
            ScrimType entity = null;

            try
            {
                if (dto.ID == 0)
                {
                    entity = new ScrimType();
                    Mapper.Map(dto, entity);
                    _repository.Repository <ScrimType>().Insert(entity);
                }
                else
                {
                    entity = GetById(dto.ID);
                    Mapper.Map(dto, entity);
                    _repository.Repository <ScrimType>().Update(entity);
                }
                _repository.Save();
            }
            catch (DbEntityValidationException valEx)
            {
                HandleValidationException(valEx);
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw;
            }
            return(entity);
        }
        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);
        }
        public int Add(ScrimTypeDto dto)
        {
            ScrimType entity = Save(dto);

            if (entity != null)
            {
                return(entity.ID);
            }
            else
            {
                return(-1);
            }
        }
        //
        // 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));
        }
 private ScrimTypeDto MapEntity(ScrimType entity)
 {
     return(Mapper.Map <ScrimType, ScrimTypeDto>(entity));
 }