private ProdLineTypeModel GetProductionLineType(int lineTypeId)
        {
            ProdLineTypeModel lineType = new ProdLineTypeModel();

            using (ProdLineTypeService service = new ProdLineTypeService())
            {
                var dto = service.Get(lineTypeId);
                lineType = Mapper.Map <ProdLineTypeDto, ProdLineTypeModel>(dto);
            }
            return(lineType);
        }
        public JsonResult UpdateProdLineResult(ProductionLineManagementModel model)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                using (ProductionLineService svc = new ProductionLineService())
                {
                    var dto = svc.Get(model.Id);
                    dto = AutoMapper.Mapper.Map <ProductionLineManagementModel, ProductionLinesDto>(model, dto);

                    using (ProdLineTypeService typeSvc = new ProdLineTypeService())
                    {
                        ProdLineTypeDto typeDto = typeSvc.Get(dto.LineTypeID);
                        if (typeDto != null)
                        {
                            switch (typeDto.ProdLineTypeCode)
                            {
                            case "TPO":
                            case "RW":
                            {
                                switch (typeDto.ProdLineTypeCode)
                                {
                                case "TPO":
                                {
                                    dto.TPOMorC = model.TPOLineRolls;
                                }
                                break;

                                case "RW":
                                {
                                    dto.TPOMorC = model.RollsProcessed;
                                }
                                break;
                                }
                                dto.RCComp = "NA";
                            }
                            break;

                            case "RC":
                            case "CO":
                            {
                                switch (typeDto.ProdLineTypeCode)
                                {
                                case "RC":
                                {
                                    dto.RCComp = model.Compatibilizer;
                                }
                                break;

                                case "CO":
                                {
                                    dto.RCComp = model.Adhesive;
                                }
                                break;
                                }
                                dto.TPOMorC = "NA";
                            }
                            break;

                            default:
                            {
                                dto.TPOMorC = "NA";
                                dto.RCComp  = "NA";
                            }
                            break;
                            }
                        }
                    }

                    dto.ModifiedBy   = CurrentUser;
                    dto.LastModified = DateTime.Now;

                    if (dto.ID > 0)
                    {
                        svc.Update(dto);
                    }
                    else
                    {
                        dto.RepOrder = 1;

                        dto.DateEntered = DateTime.Now;
                        dto.EnteredBy   = CurrentUser;
                        dto.PlantID     = CurrentPlantId;
                        dto.ID          = svc.Add(dto);
                    }

                    model = AutoMapper.Mapper.Map <ProductionLinesDto, ProductionLineManagementModel>(dto);
                }

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

            model.ResponseMessage = responseMessage;

            return(Json(model, JsonRequestBehavior.AllowGet));
        }