public async Task <IActionResult> Put(int id, [FromBody] TagListing value) { value.EnsureNotNull(HttpStatusCode.BadRequest); if (!this.Validate()) { return(this.BadRequest(this.ModelState)); } Tag entity = this._tagRepository.FindById(id).EnsureNotNull(); this.EntityOwnerService.EnsureOwner(entity, this.OwnerId); this._mapper.Map(value, entity); await this._tagRepository.SaveChangesAsync(); return(this.NoContent()); }
public async Task <IActionResult> Post([FromBody] TagListing value) { value.EnsureNotNull(HttpStatusCode.BadRequest); if (!this.Validate()) { return(this.BadRequest(this.ModelState)); } var entity = new Tag(); this.EntityOwnerService.AssignOwner(entity, this.OwnerId); this._mapper.Map(value, entity); this._tagRepository.Add(entity); await this._tagRepository.SaveChangesAsync(); return(this.CreatedAtRoute("Tag-Get", new { id = entity.Id }, this.Get(entity.Id))); }