/// <summary> /// Submit Store geo tag using multipart /// </summary> /// <param name="geoTagBO"></param> /// <returns></returns> public int SubmitStoreGeoTag(StoreGeoTagBO geoTagBO) { StoreGeoTag storeGeoTag = new StoreGeoTag(); ObjectMapper.Map(geoTagBO, storeGeoTag); int status = StoreRepository.SubmitStoreGeoTag(storeGeoTag); return(status); }
/// <summary> /// Upload Geo tag Image through Stream /// </summary> /// <param name="image">geo image stream</param> /// <returns>returns image name if successfully uploaded else blank</returns> //[SecureOperation] public JsonResponse <string> UploadGeoImageStream(Stream image) { JsonResponse <string> response = new JsonResponse <string>(); try { ExceptionEngine.AppExceptionManager.Process(() => { var parser = new MultipartFormDataParser(image); var StoreID = Convert.ToInt32(parser.Parameters["StoreID"].Data); var Latitude = Convert.ToString(parser.Parameters["Latitude"].Data); var Longitude = Convert.ToString(parser.Parameters["Longitude"].Data); var UserID = Convert.ToInt64(parser.Parameters["userid"].Data); var UserOption = parser.Parameters["UserOption"].Data; bool?UserOptionBool = null; if (UserOption != null && UserOption != "null") { UserOptionBool = Convert.ToBoolean(UserOption); } // Files are stored in a list: //var file = parser.Files.First(); // Loop through all the files int counter = 0; string fileDirectory = string.Empty; fileDirectory = AppUtil.GetUploadDirectory(AspectEnums.ImageFileTypes.Store); string newFileName = null; foreach (var file in parser.Files) { string filename = file.FileName; if (Directory.Exists(fileDirectory)) { FileStream fileData = null; newFileName = AppUtil.GetUniqueKey().ToUpper() + DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("/", "") + counter.ToString() + ".jpeg"; string uploadedFileName = fileDirectory + @"\" + newFileName; #region Step 1: Save Image //fileData = new FileStream(file.Data); using (fileData = new FileStream(uploadedFileName, FileMode.Create, FileAccess.Write, FileShare.None)) { file.Data.CopyTo(fileData); // fileData.Close(); file.Data.Close(); //fileData.Write(file.Data); } #endregion } // response.SingleResult = newFileName; } #region Step 2: Save the Content StoreGeoTagBO storeGeoTagBO = new StoreGeoTagBO() { StoreID = StoreID, UserID = UserID, Lattitude = Latitude, Longitude = Longitude, PictureFileName = newFileName, UserOption = UserOptionBool }; int dataCount = StoreBusinessInstance.SubmitStoreGeoTag(storeGeoTagBO); if (dataCount > 0) { response.IsSuccess = true; } #endregion response.IsSuccess = true; }, AspectEnums.ExceptionPolicyName.ServiceExceptionPolicy.ToString()); } catch (Exception ex) { response.Message = ex.Message; } return(response); }