public IActionResult Post([FromBody] OrganizationModel organization) { if (organization == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(new ObjectResult(ModelState)); } var organizationEntity = organization.Export(); _schedulerContext.Organizations.Add(organizationEntity); _schedulerContext.SaveChanges(); return(new ObjectResult(organization)); }
public IActionResult Put(int id, [FromBody] OrganizationModel organization) { UserCanAccessOrganization(id); if (organization == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(new ObjectResult(ModelState)); } var organizationEntity = _schedulerContext.Organizations.Single(o => o.OrganizationId == id); organization.Export(organizationEntity); _schedulerContext.SaveChanges(); return(new ObjectResult(organization)); }