public ActionResult Update([FromBody] InfectedDto dto) { _infectedCollection.UpdateOne(Builders <Infected> .Filter.Where(_ => _.Birthday == dto.Birthday), Builders <Infected> .Update.Set("Gender", dto.Gender)); return(Ok("Document successfully updated.")); }
public ActionResult UpdateInfected([FromBody] InfectedDto dto) { _infectedsColletions.UpdateOne(Builders <Infected> .Filter.Where(_ => _.BirthDate == dto.BirthDate), Builders <Infected> .Update.Set("gender", dto.Gender)); var infecteds = _infectedsColletions.Find(Builders <Infected> .Filter.Empty).ToList(); return(Ok("Sucessful updated.")); }
// Do body da requisição nós esperamos um json com padrão dos atributos da classe InfectedDto public IActionResult PostInfected([FromForm] InfectedDto dto) { var infected = new Infected(dto.Birthday, dto.Sex, dto.Latitude, dto.Longitude); _infectedCollection.InsertOne(infected); return(StatusCode(201, "Infectado adicionado com sucesso!")); }
public IActionResult UpdateInfected([FromBody] InfectedDto infectedDto) { _infectedCollection.UpdateOne(Builders <Infected> .Filter.Where(e => e.DateTime == infectedDto.DateTime), Builders <Infected> .Update.Set("Gender", infectedDto.Gender)); //var infectedList = _infectedCollection.Find(Builders<Infected>.Filter.Empty).ToList(); return(Ok("Atualizado com sucesso!!")); }
public ActionResult UpdateInfected([FromBody] InfectedDto dto) { _infectedCollection.UpdateOne(Builders <Infected> .Filter.Where(_ => _.BirthDate == dto.BirthDate), Builders <Infected> .Update.Set("gender", dto.Gender)); return(Ok("Atualizado com sucesso")); }
public ActionResult Create([FromBody] InfectedDto dto) { var infected = new Infected(dto.Birthday, dto.Gender, dto.Latitude, dto.Longitude); _infectedCollection.InsertOne(infected); return(StatusCode(201, "Infected successfully added to DB.")); }
public ActionResult <Infected> CreateInfected([FromBody] InfectedDto dto) { var infected = new Infected(dto.birthDate, dto.Gender, dto.Latitude, dto.Longitude); _infectedCollection.InsertOne(infected); return(Created(nameof(CreateInfected), infected)); }
public IActionResult UpdateInfected([FromForm] InfectedDto dto) { _infectedCollection.UpdateOne(Builders <Infected> .Filter.Where(prop => prop.Birthday == dto.Birthday), // Aqui o update atualiza uma única propriedade, replace todo o documento. Builders <Infected> .Update.Set("sex", dto.Sex)); return(Ok("Atualizado com sucesso!")); }
public ActionResult SaveInfected([FromBody] InfectedDto dto) { var infectado = new Infected(dto.Birthday, dto.Gender, dto.Latitude, dto.Longitude); _infectadosCollection.InsertOne(infectado); return(StatusCode(201, "Infected added successful")); }
public ActionResult SalvarInfectado([FromBody] InfectedDto dto) { var Infected = new Infected(dto.DataNascimento, dto.Sexo, dto.Latitude, dto.Longitude); _infectedCollection.InsertOne(Infected); return(StatusCode(201, "Infectado adicionado com sucesso")); }
public ActionResult SaveInfected([FromBody] InfectedDto dto) { var infected = new Infected(dto.BirthDate, dto.Gender, dto.Latitude, dto.Longitude); _infectedCollection.InsertOne(infected); return(StatusCode(201, "Infectado adicionado com sucesso")); }
public ActionResult SaveInfected([FromBody] InfectedDto dto) { var infected = new Infected(dto.BirthDate, dto.Gender, dto.Latitude, dto.Longitude); _infectedsColletions.InsertOne(infected); return(StatusCode(201, "Infected successfully registered ")); }
public ActionResult SaveInfected([FromBody] InfectedDto dto) { var infected = new Infected(dto.BirthDate, dto.Gender, dto.Latitude, dto.Longitude); _infectedsCollection.InsertOne(infected); return(StatusCode(201, "Infected sucessfully included")); // http statuscode 201 created }
public IActionResult AddInfected([FromBody] InfectedDto infectedDto) { var infected = new Infected( infectedDto.DateTime, infectedDto.Gender, infectedDto.longitude, infectedDto.latitude); _infectedCollection.InsertOne(infected); return(Ok("Infectado inserido com sucesso!")); }
public ActionResult UpdateInfected(string id, [FromBody] InfectedDto dto) { // Faz o filtro baseado no Id var filter = Builders <Infected> .Filter.Where(_ => _.Id == id); //Atualiza também a location para não ter inconsistência de dados var location = new GeoJson2DGeographicCoordinates(dto.Longitude, dto.Latitude); var update = Builders <Infected> .Update.Set("name", dto.Name).Set("dateBirth", dto.DateBirth).Set("sex", dto.Sex.ToUpper()) .Set("location", location).Set("latitude", dto.Latitude).Set("longitude", dto.Longitude).CurrentDate("lastModified"); _infectedsCollection.UpdateOne(filter, update); // Atualiza um documento return(Ok("Atualizado com sucesso!")); // Resposta }
public ActionResult DeleteInfected([FromBody] InfectedDto dto) { _infectadosCollection.DeleteOne(Builders <Infected> .Filter.Where(x => x.Birthday == dto.Birthday)); return(Ok("Deleted")); }
public ActionResult ChangeInfected([FromBody] InfectedDto dto) { _infectadosCollection.UpdateOne(Builders <Infected> .Filter.Where(x => x.Birthday == dto.Birthday), Builders <Infected> .Update.Set("Gender", dto.Gender)); return(Ok("Changed")); }