public ActionResult EditLand(LandAnnouncement land) { User authenticatedUser = _userRepository.GetUserByPhone(User.Identity.Name); string errormessage = Translation.Translation.InvalidAnnouncementMessage; if (ModelState.IsValid) { if (land.Address.HasValue) { if (saveAnnouncement(land, authenticatedUser)) { TempData["message"] = string.Format(Translation.Translation.CabinetDataSavedMessage); return(RedirectToAction("Announcements", new { phone = authenticatedUser.Phone })); } else { throw new Exception(Translation.Translation.AccessIsDeniedMessage); } } else { errormessage = Translation.Translation.InvalidAddressMessage; } } ViewBag.User = authenticatedUser; ModelState.AddModelError("", errormessage); return(View(land)); }
public ActionResult AddLand() { string message = Translation.Translation.AccessIsDeniedMessage; User authenticatedUser = _userRepository.GetUserByPhone(User.Identity.Name); if (authenticatedUser != null) { if (authenticatedUser.Apartments.Count < authenticatedUser.Profile.MaxAnnouncements) { LandAnnouncement land = new LandAnnouncement(); land.User = authenticatedUser; _announcementRepository.Add(land); _announcementRepository.SaveChanges(); return(RedirectToAction("EditLand", new { id = land.AnnouncementID })); } else { message = Translation.Translation.ProfileAnnouncementsLimitMessage; } } TempData["message"] = message; return(RedirectToAction("Announcements", new { phone = User.Identity.Name })); }
private Announcement createAnnouncement(int j, User user) { Announcement an = null; if (j % 3 == 0) { ApartmentAnnouncement apartment = new ApartmentAnnouncement(); apartment.Balcony = PresentTypeValue.Present; apartment.Floor = j; apartment.MaxFloor = j * 3; apartment.RoomsNumber = j % 4; apartment.TotalSquare = new Square() { Value = j % 100, Unit = SquareUnit.SquareMeters }; an = apartment; } else { if (j % 3 == 1) { HouseAnnouncement house = new HouseAnnouncement(); house.TotalSquare = new Square() { Value = j % 20, Unit = SquareUnit.Are }; an = house; } else { LandAnnouncement land = new LandAnnouncement(); land.TotalSquare = new Square() { Value = j % 20, Unit = SquareUnit.Are }; an = land; } } an.Type = AnnouncementType.Buy; an.Currency = Currency.Hryvna; an.Price = j * 1000; an.IsVisible = true; an.Sold = false; an.User = user; an.Address.AddressType = AddressType.City; an.Address.AdministrativeArea = j.ToString(); an.Address.LocalityName = j.ToString(); an.Address.District = j.ToString(); an.Address.Street = j.ToString(); return(an); }
public override string GetHtmlDescription() { LandAnnouncement land = Announcement as LandAnnouncement; string description = string.Empty; if (land != null) { description += string.Format("{0}: {1} {2}<br/>", Translation.Translation.LandsDetailsPageSquareLabel, land.TotalSquare.Value, EnumsToSelectedListItems.GetTextFromEnumValue(land.TotalSquare.Unit)); description += string.Format("{0}: {1} {2}<br/>", Translation.Translation.ApartmentDetailsPagePriceLabel, land.Price, EnumsToSelectedListItems.GetTextFromEnumValue(land.Currency)); } return(Translation.Translation.LandAnnouncementLabel + " " + base.GetHtmlDescription() + "<br/>" + description); }
public ActionResult EditLand(int id) { LandAnnouncement land = _announcementRepository.GetById(id) as LandAnnouncement; User authenticatedUser = _userRepository.GetUserByPhone(User.Identity.Name); if (authenticatedUser == land.User) { ViewBag.User = authenticatedUser; return(View(land)); } else { throw new Exception(Translation.Translation.AccessIsDeniedMessage); } }
public ActionResult LandDetails(int id) { LandAnnouncement land = _announcementRepository.GetById(id) as LandAnnouncement; return(View(land)); }