public async Task<IHttpActionResult> PostPartner(Partner partner) { if (!ModelState.IsValid) { return BadRequest(ModelState); } partner.Id = Guid.NewGuid(); partner.validation_id = Guid.NewGuid(); partner.activated = false; partner.date_created = DateTime.Today; db.Partners.Add(partner); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (PartnerExists(partner.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = partner.Id }, partner); }
public async Task<IHttpActionResult> PutPartner(Guid id, Partner partner) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != partner.Id) { return BadRequest(); } db.Entry(partner).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PartnerExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }