Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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));
        }