// [HttpPost] public ActionResult DeletePropertyPhotoMap(int propertyPhotoMapId) { try { // bool status = false; // string msg = string.Empty; var userId = Convert.ToInt32(((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId); if (BL_tblPropertyPhotoMap.DeleteRecordById(propertyPhotoMapId, userId) == 1) { TempData["msg"] = "Photo Deleted successfully!"; // status = true; // msg = "Photo Deleted successfully!"; } else { TempData["ERROR"] = "Something went wrong, Please try refreshing the page."; //msg = "Something went wrong ! Please try the refreshing page."; } //return Json(new { status = status, msg = msg }, JsonRequestBehavior.AllowGet); } catch (Exception e) { TempData["ERROR"] = e.Message; // var jsonResult = Json(new { status = false, msg = e.Message }, JsonRequestBehavior.AllowGet); //return jsonResult; } return(RedirectToAction("Index")); }
public ActionResult MapPropetyImages(IEnumerable <etblPropetyPhotoMap> unMappedEtblPropetyPhotoList) { if (ModelState.IsValid) { try { if (unMappedEtblPropetyPhotoList != null && unMappedEtblPropetyPhotoList.Count() > 0) { //var roomTypeList = unMappedEtblPropetyPhotoList.Where(x => x.iPhotoCatId == 1).FirstOrDefault().bIsPrimaryH = true; //foreach (var subCatId in unMappedEtblPropetyPhotoList.Select(x => x.iPhotoSubCatId).ToList()) //{ // unMappedEtblPropetyPhotoList.Where(x => x.iPhotoSubCatId == subCatId).FirstOrDefault().bIsPrimaryR = true; //} var userId = Convert.ToInt32(((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId); foreach (var item in unMappedEtblPropetyPhotoList) { if (item.iPhotoCatId.GetValueOrDefault() != 0 && item.iPhotoSubCatId.GetValueOrDefault() != 0) { item.bIsMapped = true; } else { item.bIsMapped = false; } item.iActionBy = userId; item.dtActionDate = DateTime.Now; } int result = BL_tblPropertyPhotoMap.UpdateMultipleRecord(unMappedEtblPropetyPhotoList.ToArray()); if (result == 1) { if (Session["PropId"] != null) { var propertyId = Convert.ToInt32(Session["PropId"].ToString()); var defaultImageResult = BL_tblPropertyPhotoMap.SetDefaultImages(propertyId); } } TempData["msg"] = "Photo Mapped successfully !"; } else { TempData["msg"] = "An unknown error had happend, Please try again."; } } catch (Exception ex) { TempData["ERROR"] = ex.Message; throw; } } return(RedirectToAction("Index")); }
public ActionResult UnmappedPropertyImages() { try { var propertyId = Convert.ToInt32(Session["PropId"].ToString()); ViewBag.categoryList = BL_tblPhotoCategoryM.GetAllRecords(); var recordList = BL_tblPropertyPhotoMap.GetUnMappedProperty(propertyId); PropertyImageMapViewModel viewModel = new PropertyImageMapViewModel(); viewModel.UnMappedEtblPropetyPhotoList = recordList; return(PartialView(viewModel)); } catch (Exception ex) { throw ex; } }
public ActionResult UpdatePropertyPhotoMap(etblPropetyPhotoMap etblPropetyPhotoMap, long?roomId) { try { bool status = false; string msg = string.Empty; int result = -1; var userId = Convert.ToInt32(((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId); etblPropetyPhotoMap.iActionBy = userId; if (roomId.HasValue) { result = BL_tblPropertyPhotoMap.UpdateMappedRooms(etblPropetyPhotoMap); } else { result = BL_tblPropertyPhotoMap.UpdateMappedProeprty(etblPropetyPhotoMap); } if (result == 1) { TempData["msg"] = "Photo Mapping updated successfully!"; msg = "Photo Mapping updated successfully!"; status = true; } else { TempData["ERROR"] = "Sorry! Something went wrong, Please try refreshing the page."; msg = "Sorry! Something went wrong, Please try refreshing the page."; } var jsonResult = Json(new { status = status, msg = msg }, JsonRequestBehavior.AllowGet); return(jsonResult); } catch (Exception e) { var jsonResult = Json(new { status = false, msg = e.Message }, JsonRequestBehavior.AllowGet); return(jsonResult); } }
public ActionResult Index(IEnumerable <HttpPostedFileBase> photos) { try { bool isSavedSuccessfully = false; if (photos != null) { if (Session["PropId"] != null) { var propertyId = Convert.ToInt32(Session["PropId"].ToString()); IList <etblPropetyPhotoMap> etblPropetyImageMList = new List <etblPropetyPhotoMap>(); string s_propertyId = propertyId.ToString(); //if(propertyId < 10) //{ // s_propertyId = "00" + propertyId.ToString(); //} //else if(propertyId < 100) //{ // s_propertyId = "0" + propertyId.ToString(); //} foreach (var uploadedFile in photos) { if (IsValideImage(uploadedFile)) { using (MemoryStream target = new MemoryStream()) { uploadedFile.InputStream.CopyTo(target); byte[] data = target.ToArray(); var uniqueFileName = Guid.NewGuid().ToString() + Path.GetExtension(uploadedFile.FileName); var currentUploadedFileUrl = clsUtils.fnUploadFileINBlobStorage(s_propertyId, uniqueFileName, data, true); System.Drawing.Image image = System.Drawing.Image.FromStream(new System.IO.MemoryStream(data)); var etblPropertyPhotoMap = new etblPropetyPhotoMap(); etblPropertyPhotoMap.iPropId = propertyId; etblPropertyPhotoMap.bIsMapped = false; etblPropertyPhotoMap.sImgUrl = propertyId.ToString() + "/" + uniqueFileName; etblPropertyPhotoMap.UniqueAzureFileName = uniqueFileName; etblPropertyPhotoMap.dtActionDate = DateTime.Now; etblPropertyPhotoMap.iActionBy = Convert.ToInt16(((OneFineRateBLL.BL_Login.UserDetails)Session["UserDetails"]).iUserId); if (image.Height >= 1080 && image.Width >= 1360) { etblPropertyPhotoMap.bIsHighRes = true; } else { etblPropertyPhotoMap.bIsHighRes = false; } etblPropertyPhotoMap.iResolutionH = (short)image.Height; etblPropertyPhotoMap.iResolutionW = (short)image.Width; etblPropetyImageMList.Add(etblPropertyPhotoMap); } } else { TempData["ERROR"] = "Invalid Images ! Please upload only .jpg, .png, .jpeg or .bmp images"; return(View()); } } BL_tblPropertyPhotoMap.AddMultipleRecord(etblPropetyImageMList.ToArray()); isSavedSuccessfully = true; } if (isSavedSuccessfully) { TempData["msg"] = "Photos uploaded successfully !"; return(Json(new { Message = "Files uploaded successfully !" })); } else { return(Json(new { status = "error", Message = "Error in saving file" })); } } return(View()); } catch (Exception ex) { TempData["ERROR"] = ex.Message; return(Json(new { Message = ex.Message })); } }