Exemplo n.º 1
0
        public IActionResult CreateRestaurant(RestaurantClient reqObj)
        {
            if (reqObj == null)
            {
                BadRequest();
            }
            JSONRetObj <int?> retObj = new JSONRetObj <int?>();

            try
            {
                retObj.IsSuccess = true;
                retObj.Message   = "";
                Restaurant    restaurant    = Mapper.Map <Restaurant>(reqObj);
                RestaurantDTO restaurantDto = Mapper.Map <RestaurantDTO>(restaurant);
                int           foodMarkerId  = _repoRestaurant.Post(restaurantDto);
                retObj.ResponseObj = foodMarkerId;
            }
            catch (Exception ex)
            {
                retObj.IsSuccess   = false;
                retObj.Message     = ex.Message;
                retObj.ResponseObj = null;
            }

            ViewData["RetObj"] = retObj;

            return(View("_Success"));
        }
Exemplo n.º 2
0
        public int Post([FromBody] RestaurantClient reqObj)
        {
            if (reqObj == null)
            {
                BadRequest();
            }

            Restaurant restaurant = _mapper.Map <Restaurant>(reqObj);
            int        id         = _service.PostRestaurant(restaurant);

            return(id);
        }
Exemplo n.º 3
0
        public IEnumerable <RestaurantClient> Get()
        {
            IEnumerable <Restaurant> restaurants = _service.GetRestaurants();
            List <RestaurantClient>  retLst      = new List <RestaurantClient>();

            foreach (var restaurant in restaurants)
            {
                RestaurantClient restaurantRet = _mapper.Map <RestaurantClient>(restaurant);
                retLst.Add(restaurantRet);
            }

            return(retLst);
        }