public OrganizationTypeViewModel BuildNew(OrganizationType organizationType) { var organizationTypeViewModel = new OrganizationTypeViewModel() { Id = organizationType.Id, Title = organizationType.Title }; return(organizationTypeViewModel); }
public async Task <IActionResult> PostOrganizationType([FromBody] OrganizationTypeViewModel model) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } var entity = this.mapper.Map <OrganizationType>(model); await this.repository.InsertAsync(entity); return(this.CreatedAtAction( "GetOrganizationType", new { id = entity.Id }, model)); }
public async Task <IActionResult> PutOrganizationType( [FromRoute] long id, [FromBody] OrganizationTypeViewModel model) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } var entity = await this.repository.FindByIdAsync(id); if (entity == null) { return(this.NotFound()); } this.mapper.Map(model, entity); await this.repository.UpdateAsync(entity); return(this.NoContent()); }