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