Beispiel #1
0
        public async Task <OkObjectResult> Login(string email, string password)
        {
            if (SDHelper.IsValueNotNull(email) && SDHelper.IsValueNotNull(password))
            {
                var authenticateRequest =
                    await AuthenticationRequest(email, password);

                return(Ok(authenticateRequest));
            }

            return(Ok(new LoginJsonModel("Email or password are empty", false)));
        }
Beispiel #2
0
        public async Task <OkObjectResult> Register(string email, string password,
                                                    string username = null, string phone = null)
        {
            if (SDHelper.IsValueNotNull(email) && SDHelper.IsValueNotNull(password))
            {
                var registrationRequest =
                    await RegistrationRequest(email, password);

                return(Ok(registrationRequest));
            }

            return(Ok(new UserJsonModel("Email or password are empty", false)));
        }
Beispiel #3
0
        public async Task <OkObjectResult> GetUserById(string id)
        {
            if (SDHelper.IsValueNotNull(id))
            {
                var user = await service.Find(s => s.Id == id);

                if (user != null)
                {
                    return(Ok(mapper.Map <User, UserJsonModel>(user)));
                }
                return(Ok(new UserJsonModel()
                {
                    Error = "There is no user with this email", IsSuccess = false
                }));
            }
            return(Ok(new UserJsonModel("Email field is empty", false)));
        }
Beispiel #4
0
        public async Task <OkObjectResult> GetProductById(int id)
        {
            if (SDHelper.IsValueNotNull(id.ToString()))
            {
                var user = await service.Find(s => s.Id == id);

                if (user != null)
                {
                    return(Ok(mapper.Map <Product, ProductJsonModel>(user)));
                }
                return(Ok(new ProductJsonModel()
                {
                    Error = "There is no product with this Id", IsSuccess = false
                }));
            }
            return(Ok(new ProductJsonModel("Id field is empty", false)));
        }