Example #1
0
        public async Task <IActionResult> Login([FromBody] SellerLoginDto loginCreds)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _repo.Login(loginCreds);

            if (result.IsSucces)
            {
                var returnDto = new SellerReturnDto()
                {
                    Credentials = result.Content,
                    Token       = result.Message
                };

                return(Ok(returnDto));
            }

            return(Unauthorized(loginCreds));
        }
Example #2
0
        public async Task <IActionResult> Register([FromBody] SellerRegisterDto regCreds)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _repo.Register(regCreds);

            if (result.IsSucces)
            {
                var returnDto = new SellerReturnDto()
                {
                    Credentials = result.Content,
                    Token       = result.Message
                };

                return(Ok(returnDto));
            }

            return(StatusCode(500, result.Message));
        }