Esempio n. 1
0
        public ActionResult EditHouse(HouseAnnouncement house)
        {
            User   authenticatedUser = _userRepository.GetUserByPhone(User.Identity.Name);
            string errormessage      = Translation.Translation.InvalidAnnouncementMessage;

            if (ModelState.IsValid)
            {
                if (house.Address.HasValue)
                {
                    if (saveAnnouncement(house, 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(house));
        }
Esempio n. 2
0
        public ActionResult AddHouse()
        {
            string message           = Translation.Translation.AccessIsDeniedMessage;
            User   authenticatedUser = _userRepository.GetUserByPhone(User.Identity.Name);

            if (authenticatedUser != null)
            {
                if (authenticatedUser.Apartments.Count < authenticatedUser.Profile.MaxAnnouncements)
                {
                    HouseAnnouncement house = new HouseAnnouncement();
                    house.User = authenticatedUser;
                    _announcementRepository.Add(house);
                    _announcementRepository.SaveChanges();
                    return(RedirectToAction("EditHouse", new { id = house.AnnouncementID }));
                }
                else
                {
                    message = Translation.Translation.ProfileAnnouncementsLimitMessage;
                }
            }

            TempData["message"] = message;

            return(RedirectToAction("Announcements", new { phone = User.Identity.Name }));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        public override string GetHtmlDescription()
        {
            HouseAnnouncement house       = Announcement as HouseAnnouncement;
            string            description = string.Empty;

            if (house != null)
            {
                description  = string.Format("{0}: {1}<br/>", Translation.Translation.ApartmentDetailsPageRoomsCountLabel, house.RoomsNumber);
                description += string.Format("{0}: {1} {2}<br/>", Translation.Translation.LandsDetailsPageSquareLabel, house.TotalSquare.Value, EnumsToSelectedListItems.GetTextFromEnumValue(house.TotalSquare.Unit));
                description += string.Format("{0}: {1} {2}<br/>", Translation.Translation.HousesDetailsPageSquareLabel, house.LivingSquare.Value, EnumsToSelectedListItems.GetTextFromEnumValue(house.LivingSquare.Unit));
                description += string.Format("{0}: {1} {2}<br/>", Translation.Translation.ApartmentDetailsPagePriceLabel, house.Price, EnumsToSelectedListItems.GetTextFromEnumValue(house.Currency));
            }
            return(Translation.Translation.LandAnnouncementLabel + " " + base.GetHtmlDescription() + "<br/>" + description);
        }
Esempio n. 5
0
        public ActionResult EditHouse(int id)
        {
            HouseAnnouncement house = _announcementRepository.GetById(id) as HouseAnnouncement;
            User authenticatedUser  = _userRepository.GetUserByPhone(User.Identity.Name);

            if (authenticatedUser == house.User)
            {
                ViewBag.User = authenticatedUser;
                return(View(house));
            }
            else
            {
                throw new Exception(Translation.Translation.AccessIsDeniedMessage);
            }
        }
        public ActionResult HouseDetails(int id)
        {
            HouseAnnouncement house = _announcementRepository.GetById(id) as HouseAnnouncement;

            return(View(house));
        }