Beispiel #1
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"));
        }
Beispiel #2
0
 public int PostFoodMarker(FoodMarker foodMarker)
 {
     FoodMarkerDTO foodMarkerDTO = _mapper.Map<FoodMarkerDTO>(foodMarker);
     int id = _repo.Post(foodMarkerDTO);
     return id;
 }