Exemplo n.º 1
0
        public async Task <IActionResult> Create([FromBody] CreateManagerRequest createManagerRequest)
        {
            var manager = new Manager
            {
                FirstName        = createManagerRequest.FirstName,
                LastName         = createManagerRequest.LastName,
                PersonalIdentity = createManagerRequest.PersonalIdentity
            };

            var createdManager = await _repo.CreateManagerAsync(manager);

            if (!createdManager)
            {
                return(BadRequest(new { Error = "There was an error creating a new Manager" }));
            }

            var response = new ManagerResponse
            {
                Id               = manager.Id,
                FirstName        = manager.FirstName,
                LastName         = manager.LastName,
                PersonalIdentity = manager.PersonalIdentity
            };

            return(Created("", response));
        }