public JsonResult SaveProdComment(int?productionLineId, int?shiftId, int?workOrderId, DateTime?productionDate, string comment)
        {
            ProdCommentModel model = new ProdCommentModel();

            using (TPO.Services.Production.ProdCommentService service = new Services.Production.ProdCommentService())
            {
                var dto = service.GetByLineShiftWorkOrderDate(productionLineId.Value, shiftId.Value, workOrderId.Value, productionDate.Value);
                dto.ModifiedBy   = CurrentUser;
                dto.LastModified = DateTime.Now;
                dto.Comment      = comment;

                if (dto.ID == 0)
                {
                    dto.LineID         = productionLineId.Value;
                    dto.ShiftID        = shiftId.Value;
                    dto.WorkOrderID    = workOrderId.Value;
                    dto.ProductionDate = productionDate.Value;
                    dto.EnteredBy      = CurrentUser;
                    dto.DateEntered    = DateTime.Now;

                    dto.ID = service.Add(dto);
                }
                else
                {
                    service.Update(dto);
                }

                // refresh and pass it back
                dto = service.Get(dto.ID);
                AutoMapper.Mapper.Map(dto, model);
            }

            return(Json(model, JsonRequestBehavior.DenyGet));
        }
Example #2
0
        public JsonResult FetchProdComment(int?productionLineId, int?shiftId, int?workOrderId, DateTime?productionDate)
        {
            ProdCommentModel model = new ProdCommentModel();

            if (productionLineId.HasValue && shiftId.HasValue && workOrderId.HasValue && productionDate.HasValue)
            {
                using (TPO.Services.Production.ProdCommentService service = new Services.Production.ProdCommentService())
                {
                    var dto = service.GetByLineShiftWorkOrderDate(productionLineId.Value, shiftId.Value, workOrderId.Value, productionDate.Value);
                    model = AutoMapper.Mapper.Map <ProdCommentDto, ProdCommentModel>(dto);
                }
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }