public object PutDefect([FromBody] IEnumerable <DefectDetail> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Id == 0))
            {
                return(Result.GenError <Result>(Error.DefectNotExist));
            }
            var markedDateTime = DateTime.Now;

            foreach (var detail in details)
            {
                detail.MarkedDateTime = markedDateTime;
                detail.Remark         = detail.Remark ?? "";
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                var ids = details.Select(x => x.Id);
                var cnt = DefectHelper.Instance.GetCountByIds(ids);
                if (cnt != details.Count())
                {
                    return(Result.GenError <Result>(Error.DefectNotExist));
                }
                DefectHelper.Enable(details);
            }
            else
            {
                if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
                {
                    return(Result.GenError <Result>(Error.DefectDuplicate));
                }
                var wId   = details.FirstOrDefault()?.WorkshopId ?? 0;
                var sames = details.Select(x => x.Name);
                var ids   = details.Select(x => x.Id);
                if (DefectHelper.GetHaveSame(wId, sames, ids))
                {
                    return(Result.GenError <Result>(Error.DefectIsExist));
                }
                var cnt = DefectHelper.Instance.GetCountByIds(ids);
                if (cnt != details.Count())
                {
                    return(Result.GenError <Result>(Error.DefectNotExist));
                }
                DefectHelper.Instance.Update(details);
            }
            return(Result.GenError <Result>(Error.Success));
        }
        public object PostDefect([FromBody] IEnumerable <DefectDetail> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DefectNotEmpty));
            }
            if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
            {
                return(Result.GenError <Result>(Error.DefectDuplicate));
            }

            var wId   = details.FirstOrDefault()?.WorkshopId ?? 0;
            var sames = details.Select(x => x.Name);

            if (DefectHelper.GetHaveSame(wId, sames))
            {
                return(Result.GenError <Result>(Error.DefectIsExist));
            }

            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DefectNotEmpty));
            }

            var userId         = Request.GetIdentityInformation();
            var markedDateTime = DateTime.Now;

            foreach (var detail in details)
            {
                detail.CreateUserId   = userId;
                detail.MarkedDateTime = markedDateTime;
                detail.Remark         = detail.Remark ?? "";
            }
            DefectHelper.Instance.Add(details);
            return(Result.GenError <Result>(Error.Success));
        }