Пример #1
0
        public async Task <IActionResult> GetAllHouses(string world, string houseID)
        {
            var response = new Response <HouseDTO>
            {
                Succeed = false
            };

            if (string.IsNullOrEmpty(world))
            {
                response.Message = "The world name must be provided";
                return(BadRequest(response));
            }

            if (string.IsNullOrEmpty(houseID))
            {
                response.Message = "The house id must be provided";
                return(BadRequest(response));
            }

            try
            {
                var r = await _houseService.GetHouse(world, houseID);

                response.Result  = _mapper.Map <HouseDTO>(r.Response);
                response.Succeed = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                return(StatusCode(StatusCodes.Status500InternalServerError, response));
            }
            return(Ok(response));
        }
Пример #2
0
        public ActionResult <House> GetHouse(string houseName)
        {
            var house = _houseService.GetHouse(houseName);

            if (house == null)
            {
                return(NotFound());
            }
            return(Ok(house));
        }
Пример #3
0
 public IActionResult GetHouse(int houseId)
 {
     try
     {
         return(Ok(_houseService.GetHouse(houseId)));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
Пример #4
0
        public IActionResult GetHouse(int houseId)
        {
            //get current user
            var       currentUserId = _userManager.GetUserId(HttpContext.User);
            HouseMate currentUser   = _houseMateService.GetHouseMate(currentUserId);

            if (houseId != currentUser.HouseId)
            {
                return(BadRequest("Housemate's houseId does not match"));
            }

            House house = _houseService.GetHouse(houseId);

            return(Ok(house));
        }
Пример #5
0
 public House GetHouse(long houseId)
 {
     return(_houseService.GetHouse(houseId));
 }
Пример #6
0
        public async Task <HouseViewModel> GetHouse(int id)
        {
            var house = await _houseService.GetHouse(id);

            return(house);
        }