public Result PostSmartTaskOrderLevel([FromBody] IEnumerable <SmartTaskOrderLevel> operatorLevels) { if (operatorLevels == null || !operatorLevels.Any()) { return(Result.GenError <Result>(Error.ParamError)); } if (operatorLevels.Any(x => x.Level.IsNullOrEmpty())) { return(Result.GenError <Result>(Error.SmartTaskOrderLevelNotEmpty)); } if (operatorLevels.GroupBy(x => x.Level).Any(y => y.Count() > 1)) { return(Result.GenError <Result>(Error.SmartTaskOrderLevelDuplicate)); } var wId = operatorLevels.FirstOrDefault()?.WorkshopId ?? 0; var sames = operatorLevels.Select(x => x.Level); if (SmartTaskOrderLevelHelper.GetHaveSame(wId, sames)) { return(Result.GenError <Result>(Error.SmartTaskOrderLevelIsExist)); } var userId = Request.GetIdentityInformation(); var markedDateTime = DateTime.Now; foreach (var operatorLevel in operatorLevels) { operatorLevel.CreateUserId = userId; operatorLevel.MarkedDateTime = markedDateTime; operatorLevel.Remark = operatorLevel.Remark ?? ""; } SmartTaskOrderLevelHelper.Instance.Add(operatorLevels); return(Result.GenError <Result>(Error.Success)); }
public DataResult GetSmartTaskOrderLevel([FromQuery] int qId, int wId, bool menu) { var result = new DataResult(); result.datas.AddRange(menu ? SmartTaskOrderLevelHelper.GetMenu(qId, wId) : SmartTaskOrderLevelHelper.GetDetail(qId, wId)); if (qId != 0 && !result.datas.Any()) { result.errno = Error.SmartTaskOrderLevelNotExist; return(result); } return(result); }
public Result PutSmartTaskOrderLevel([FromBody] IEnumerable <SmartTaskOrderLevel> taskOrderLevels) { if (taskOrderLevels == null || !taskOrderLevels.Any()) { return(Result.GenError <Result>(Error.ParamError)); } if (taskOrderLevels.Any(x => x.Level.IsNullOrEmpty())) { return(Result.GenError <Result>(Error.SmartTaskOrderLevelNotEmpty)); } if (taskOrderLevels.GroupBy(x => x.Level).Any(y => y.Count() > 1)) { return(Result.GenError <Result>(Error.SmartTaskOrderLevelDuplicate)); } var wId = taskOrderLevels.FirstOrDefault()?.WorkshopId ?? 0; var sames = taskOrderLevels.Select(x => x.Level); var ids = taskOrderLevels.Select(x => x.Id); if (SmartTaskOrderLevelHelper.GetHaveSame(wId, sames, ids)) { return(Result.GenError <Result>(Error.SmartTaskOrderLevelIsExist)); } var cnt = SmartTaskOrderLevelHelper.Instance.GetCountByIds(ids); if (cnt != taskOrderLevels.Count()) { return(Result.GenError <Result>(Error.SmartTaskOrderLevelNotExist)); } var markedDateTime = DateTime.Now; foreach (var taskOrderLevel in taskOrderLevels) { taskOrderLevel.MarkedDateTime = markedDateTime; taskOrderLevel.Remark = taskOrderLevel.Remark ?? ""; } SmartTaskOrderLevelHelper.Instance.Update(taskOrderLevels); return(Result.GenError <Result>(Error.Success)); }