Ejemplo n.º 1
0
        public int Post([FromBody] FoodMarkerClient reqObj)
        {
            if (reqObj == null)
            {
                BadRequest();
            }

            FoodMarker foodMarker = _mapper.Map <FoodMarker>(reqObj);

            return(_service.PostFoodMarker(foodMarker));
        }
Ejemplo n.º 2
0
        public IEnumerable <FoodMarkerClient> Get()
        {
            var markers = _service.GetFoodMarkers();

            List <FoodMarkerClient> retLst = new List <FoodMarkerClient>();

            foreach (var marker in markers)
            {
                FoodMarkerClient foodMarkerRet = _mapper.Map <FoodMarkerClient>(marker);
                retLst.Add(foodMarkerRet);
            }

            return(retLst);
        }
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"));
        }