Exemplo n.º 1
0
        // GET: api/Customer/5
        public HttpResponseMessage Post(int id, [FromBody] LoginModel loginModel)
        {
            if (ModelState.IsValid && _customerRepository.IsAdmin(loginModel))
            {
                if (id >= 0)
                {
                    var customers = _roleTypeRepository.GetCustomers(id);

                    return(customers.Any() ?
                           Request.CreateResponse(HttpStatusCode.OK, customers)
                        : Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Can not find the customer of the roletype with {id} ID"));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The identifier must be the same or greater than 0!"));
                }
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Invalid credentials"));
            }
        }