Ejemplo n.º 1
0
        public IActionResult OfficeDetails(int id)
        {
            var office = _officesService.GetById(id);

            if (office == null)
            {
                return(NotFound()); //return 404 Not Found
            }
            return(View(office));
        }
        public IActionResult GetById(int id)
        {
            var office = _officesService.GetById(id);

            if (office == null)
            {
                return(NotFound());
            }

            var response = _mapper.Map <GetOfficeResponse>(office);

            return(Ok(response));
        }
        public async Task <IActionResult> SignUp([FromBody] SignUpRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var location = _officesService.GetById(request.LocationId.Value);

            if (location == null)
            {
                return(NotFound());
            }

            var user = new User()
            {
                UserName       = request.Email,
                Email          = request.Email,
                Name           = request.Name,
                SlackName      = request.SlackName,
                Location       = location,
                LockoutEnabled = false
            };

            var result = await _userManager.CreateAsync(user, request.Password);

            if (!result.Succeeded)
            {
                return(StatusCode((int)HttpStatusCode.Conflict, new ErrorResponse
                {
                    ErrorMessage = string.Join(Environment.NewLine, result.Errors.Select(x => x.Description))
                }));
            }

            return(NoContent());
        }