public Result PutDeviceHardware([FromBody] IEnumerable <DeviceHardware> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DeviceHardwareNotEmpty));
            }
            if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
            {
                return(Result.GenError <Result>(Error.DeviceHardwareDuplicate));
            }

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

            if (DeviceHardwareHelper.GetHaveSame(wId, sames, ids))
            {
                return(Result.GenError <Result>(Error.DeviceHardwareIsExist));
            }

            var cnt = DeviceHardwareHelper.Instance.GetCountByIds(ids);

            if (cnt != details.Count())
            {
                return(Result.GenError <Result>(Error.DeviceHardwareNotExist));
            }

            var markedDateTime = DateTime.Now;

            foreach (var process in details)
            {
                process.MarkedDateTime = markedDateTime;
                process.Remark         = process.Remark ?? "";
            }

            DeviceHardwareHelper.Instance.Update(details);
            return(Result.GenError <Result>(Error.Success));
        }
        public Result PostDeviceHardware([FromBody] IEnumerable <DeviceHardware> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DeviceHardwareNotEmpty));
            }
            if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
            {
                return(Result.GenError <Result>(Error.DeviceHardwareDuplicate));
            }

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

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

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

            foreach (var process in details)
            {
                process.CreateUserId   = userId;
                process.MarkedDateTime = markedDateTime;
                process.Remark         = process.Remark ?? "";
            }

            DeviceHardwareHelper.Instance.Add(details);
            return(Result.GenError <Result>(Error.Success));
        }