public JsonResult GetAllProductionShiftDefaults(int lineId)
        {
            List <ProductionShiftUseModel> productionShiftUse = new List <ProductionShiftUseModel>();

            using (ProductionShiftUseService service = new ProductionShiftUseService())
            {
                var dto = service.GetAllByLineId(lineId);
                productionShiftUse.AddRange(Mapper.Map <List <ProductionShiftUseDto>, List <ProductionShiftUseModel> >(dto));
                productionShiftUse.AddRange(AddMissingShifts(dto, lineId));
            }
            return(Json(productionShiftUse, JsonRequestBehavior.AllowGet));
        }
        public JsonResult UpdateRow(string row)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            ProductionShiftUseModel productionShiftUse = JsonConvert.DeserializeObject <ProductionShiftUseModel>(row);

            try
            {
                if (productionShiftUse != null)
                {
                    productionShiftUse.LastModified = DateTime.Now;
                    productionShiftUse.ModifiedBy   = CurrentUser;
                    productionShiftUse.PlantId      = CurrentPlantId;
                    ProductionShiftUseDto dto = new ProductionShiftUseDto();
                    using (ProductionShiftUseService service = new ProductionShiftUseService())
                    {
                        if (productionShiftUse.Id == 0)
                        {
                            productionShiftUse.EnteredBy   = CurrentUser;
                            productionShiftUse.DateEntered = DateTime.Now;
                            Mapper.Map(productionShiftUse, dto);
                            service.Add(dto);
                        }
                        else
                        {
                            dto = service.Get(productionShiftUse.Id);
                            Mapper.Map(productionShiftUse, dto);
                            service.Update(dto);
                        }
                    }
                }

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

            productionShiftUse.ResponseMessage = responseMessage;

            return(Json(productionShiftUse, JsonRequestBehavior.AllowGet));
        }
        public JsonResult SetAllProductionLineSchedule(string startDate)
        {
            TPO.Web.Core.ResponseMessage responseMessage;

            try
            {
                using (ProductionShiftUseService service = new ProductionShiftUseService())
                {
                    var dtos = service.GetAllByPlantId(CurrentPlantId);
                    foreach (var dto in dtos)
                    {
                        service.SetProductionLineSchedule(dto, startDate);
                    }
                }

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

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