public JsonResult getAllPropertyImages() { ErrorModel errorModel = new ErrorModel(); IEnumerable <PropertyImage> propertyImage; List <IEnumerable> pImageInfo = new List <IEnumerable>(); try { using (EasyFindPropertiesEntities dbCtx = new EasyFindPropertiesEntities()) { UnitOfWork unitOfWork = new UnitOfWork(dbCtx); //checking if the landlord id was saved in the session if (Session["userId"] != null) { var userId = (Guid)Session["userId"]; var owner = unitOfWork.Owner.GetOwnerByUserID(userId); propertyImage = unitOfWork.PropertyImage.GetAllPrimaryPropertyImageByOwnerId(owner.ID); foreach (var image in propertyImage) { //adding properties to dictionary to display image to the user Dictionary <String, String> imageInfo = new Dictionary <string, string>(); imageInfo.Add("propertyID", image.PropertyID.ToString()); imageInfo.Add("imageURL", image.ImageURL); pImageInfo.Add(imageInfo); } } } } catch (Exception ex) { errorModel = MiscellaneousHelper.PopulateErrorModel(null); return(Json(errorModel, JsonRequestBehavior.AllowGet)); } return(Json(pImageInfo, JsonRequestBehavior.AllowGet)); }
public JsonResult RequestProperty(PropertyRequisition request, String contactPurpose) { ErrorModel errorModel = new ErrorModel(); if (ModelState.IsValid) { try { using (EasyFindPropertiesEntities dbCtx = new EasyFindPropertiesEntities()) { if (Session["userId"] != null) { UnitOfWork unitOfWork = new UnitOfWork(dbCtx); Guid userId = (Guid)Session["userId"]; if (contactPurpose.Equals("requisition")) { PropertyRequisition requisition = new PropertyRequisition() { ID = Guid.NewGuid(), UserID = userId, PropertyID = request.PropertyID, Msg = request.Msg, IsAccepted = false, ExpiryDate = DateTime.Now.AddDays(7),//requisition should last for a week DateTCreated = DateTime.Now }; unitOfWork.PropertyRequisition.Add(requisition); unitOfWork.save(); var userTo = unitOfWork.Property.GetPropertyOwnerByPropID(request.PropertyID).User; //DashboardHub.BroadcastUserMessages(userTo.Email); broadcast requisition } else { var userTo = unitOfWork.Property.GetPropertyOwnerByPropID(request.PropertyID).User; Message message = new Message() { ID = Guid.NewGuid(), To = userTo.ID, From = userId, Msg = request.Msg, Seen = false, DateTCreated = DateTime.Now }; unitOfWork.Message.Add(message); unitOfWork.save(); DashboardHub.BroadcastUserMessages(userTo.Email); } } } } catch (Exception ex) { errorModel = MiscellaneousHelper.PopulateErrorModel(ModelState); } } else { errorModel = MiscellaneousHelper.PopulateErrorModel(ModelState); } MvcCaptcha.ResetCaptcha("captcha");//TODO find a way to reload captcha image after returning the response return(Json(errorModel)); }/*