public DataResult GetDeviceApplication([FromQuery] int qId, int wId, bool menu)
        {
            var result = new DataResult();

            result.datas.AddRange(menu
                ? DeviceApplicationHelper.GetMenu(wId, qId)
                : DeviceApplicationHelper.GetDetail(qId, wId));
            if (qId != 0 && !result.datas.Any())
            {
                result.errno = Error.DeviceApplicationNotExist;
                return(result);
            }
            return(result);
        }
        public Result PutDeviceApplication([FromBody] IEnumerable <DeviceApplication> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DeviceApplicationNotEmpty));
            }
            if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
            {
                return(Result.GenError <Result>(Error.DeviceApplicationDuplicate));
            }

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

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

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

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

            var markedDateTime = DateTime.Now;

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

            DeviceApplicationHelper.Instance.Update(details);
            return(Result.GenError <Result>(Error.Success));
        }
        public Result PostDeviceApplication([FromBody] IEnumerable <DeviceApplication> details)
        {
            if (details == null || !details.Any())
            {
                return(Result.GenError <Result>(Error.ParamError));
            }
            if (details.Any(x => x.Name.IsNullOrEmpty()))
            {
                return(Result.GenError <Result>(Error.DeviceApplicationNotEmpty));
            }
            if (details.GroupBy(x => x.Name).Any(y => y.Count() > 1))
            {
                return(Result.GenError <Result>(Error.DeviceApplicationDuplicate));
            }

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

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

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

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

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