Ejemplo 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"));
        }
Ejemplo n.º 2
0
        public IActionResult CreateCategory(FoodCategoryClient reqObj)
        {
            if (reqObj == null)
            {
                BadRequest();
            }

            JSONRetObj <int?> retObj = new JSONRetObj <int?>();

            try
            {
                retObj.IsSuccess = true;
                retObj.Message   = "";
                FoodCategory    foodCategory    = Mapper.Map <FoodCategory>(reqObj);
                FoodCategoryDTO foodCategoryDto = Mapper.Map <FoodCategoryDTO>(foodCategory);
                int             foodMarkerId    = _repoFoodCategory.Post(foodCategoryDto);
                retObj.ResponseObj = foodMarkerId;
            }
            catch (Exception ex)
            {
                retObj.IsSuccess   = false;
                retObj.Message     = ex.Message;
                retObj.ResponseObj = null;
            }

            ViewData["RetObj"] = retObj;

            return(View("_Success"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> CreateFoodMarker(FoodMarkerClient reqObj)
        {
            if (reqObj == null)
            {
                BadRequest();
            }

            JSONRetObj <int?> retObj = new JSONRetObj <int?>();

            try
            {
                retObj.IsSuccess = true;
                FoodMarker    foodMarker    = Mapper.Map <FoodMarker>(reqObj);
                FoodMarkerDTO foodMarkerDto = Mapper.Map <FoodMarkerDTO>(foodMarker);
                int           foodMarkerId  = _repoFoodMarker.Post(foodMarkerDto);

                foreach (var file in Request.Form.Files)
                {
                    FoodMarkerImageData postImageMeta = new FoodMarkerImageData(foodMarkerId, file.FileName);

                    var postImageMetaDto = Mapper.Map <FoodMarkerImageDataDTO>(postImageMeta);

                    postImageMeta.Id = postImageMetaDto.Id = _repoImageMeta.Post(postImageMetaDto);

                    Stream stream = file.OpenReadStream();
                    await _repoImageFile.PostFile(postImageMetaDto, file.ContentType, stream);
                }

                retObj.ResponseObj = foodMarkerId;
            }
            catch (Exception ex)
            {
                retObj.IsSuccess = false;
                retObj.Message   = ex.Message;
            }

            ViewData["RetObj"] = retObj;

            return(View("_Success"));
        }