public ActionResult AtualizarInfectado([FromBody] InfectadosDto dto) { var infectado = new Infectado(dto.DataNascimento, dto.Idade, dto.Sexo, dto.Latitude, dto.Longitude); _infectadosCollection.UpdateOne(Builders <Infectado> .Filter.Where(_ => _.DataNascimento == dto.DataNascimento), Builders <Infectado> .Update.Set("sexo", dto.Sexo)); return(Ok("Atualizado com sucesso")); }
public ActionResult SalvarInfectado([FromBody] InfectadosDto dto) { var Infectados = new Infectados(dto.DataNascimento, dto.Sexo, dto.Latitude, dto.longitude); _infectadosCollection.InsertOne(Infectados); return(StatusCode(201, "Infectado adicionado com sucesso")); }
public ActionResult SalvarInfectado([FromBody] InfectadosDto dto) { DateTime date = DateTime.Now; string dataConvert = Convert.ToString(dto.DataNascimento); string data = dataConvert.Substring(dataConvert.Length - 13, 4); string dataAtualConvert = Convert.ToString(date); string dataAtual = dataAtualConvert.Substring(dataAtualConvert.Length - 13, 4); int anoNasc = Convert.ToInt32(data); int anoAtual = Convert.ToInt32(dataAtual); dto.Idade = anoAtual - anoNasc; var infectado = new Infectado(dto.DataNascimento, dto.Idade, dto.Sexo, dto.Latitude, dto.Longitude); _infectadosCollection.InsertOne(infectado); return(StatusCode(201, "Infectado adicionado com sucesso")); }