public async Task <int> CreateAsync(KanbanModel model) { do { model.Code = CodeGenerator.Generate(); }while (DbSet.Any(d => d.Code.Equals(model.Code))); foreach (var step in model.Instruction.Steps) { step.MachineId = step.Machine.Id; step.Machine = null; } KanbanLogic.CreateModel(model); return(await DbContext.SaveChangesAsync()); }