public async Task <int> Put(SolucaoCrime model) { var solucao = await _repo.GetSolucaoCrime(model.Id); if (solucao.ArmaId == model.ArmaId && solucao.LocalId == model.LocalId && solucao.SuspeitoId == model.SuspeitoId) { return(0); } else { List <int> resultado = new List <int>(); if (solucao.SuspeitoId != model.SuspeitoId) { resultado.Add(1); } if (solucao.LocalId != model.LocalId) { resultado.Add(2); } if (solucao.ArmaId != model.ArmaId) { resultado.Add(3); } var index = new Random().Next(resultado.Count); return(resultado[index]); } }
public async Task <int> Post(SolucaoCrime model) { try { _repo.Add(model); if (await _repo.SaveChangesAsync()) { return(model.Id); } return(-1); } catch (System.Exception) { return(-1); } }