public ActionResult DeleteMobile(int id = 0) { var realty = _realtyRepository.Read(id); if (realty == null) { return(HttpNotFound()); } var isAnonumousUserCanEdit = _anonymousUserService.IsUserCanEdit(id); if (WebSecurity.CurrentUserId != realty.UserId && !User.IsInRole("Administrator")) { if (!isAnonumousUserCanEdit) { return(HttpNotFound()); } } return(View("DeleteMobile", realty)); }
public ActionResult Edit(int id) { var announcement = _repository.Read(id); if (announcement == null) { return(HttpNotFound()); } var isAnonumousUserCanEdit = _anonymousUserService.IsUserCanEdit(id); if (WebSecurity.CurrentUserId != announcement.UserId && !User.IsInRole("Administrator") && !User.IsInRole("Moderator")) { if (!isAnonumousUserCanEdit) { return(HttpNotFound()); } } if (announcement.Price.HasValue && !announcement.Currency.Rate.Equals(1.0f)) { announcement.Price = Math.Round((decimal)announcement.Price * (decimal)announcement.Currency.Rate, 2); } if (announcement.User.UserId != -1 && (announcement.Phone == null || announcement.Phone.Equals(string.Empty))) { announcement.Phone = announcement.User.Phone; } PopulateCategoryDropDownList(announcement.Category); PopulateSectionDropDownList(announcement.SectionId + "." + announcement.SubsectionId); //PopulateSubsectionDropDownList(announcement.SectionId, announcement.Subsection); PopulateCityDropDownList(announcement.City); PopulateCurrencyDropDownList(announcement.Currency); ViewBag.ImagePath = ImageProvider.PublicAnouncementImagesPath; ViewBag.UploadedImages = (announcement.Images != null) ? from image in announcement.Images select image.Link + ";" + image.IsTitular.ToString().ToLower() : null; return(View(announcement)); }
protected override bool AuthorizeCore(HttpContextBase httpContext) { var anonymousService = new AnonymousUserService(); var routId = httpContext.Request.RequestContext.RouteData.Values["id"]; var annId = 0; if (routId != null) annId = Convert.ToInt32(routId); if (annId == 0 || !anonymousService.IsUserCanEdit(annId)) { return base.AuthorizeCore(httpContext); } return true; }