Exemplo n.º 1
0
        public ActionResult Wishes()
        {
            int?personid = HttpContext.Session.GetInt32("PersonID");

            if (personid == null)
            {
                return(new UnauthorizedResult());
            }
            ViewData["LoggedIn"] = true;
            Dictionary <int, ClientWish> wishes = DbAdvanced.GetWishesByPerson((int)personid);

            return(View("Wishes", wishes));
        }
Exemplo n.º 2
0
        public ActionResult Bookmarks()
        {
            int?personid = HttpContext.Session.GetInt32("PersonID");

            if (personid == null)
            {
                return(new UnauthorizedResult());
            }

            ViewData["LoggedIn"] = true;
            Dictionary <int, string> d = DbAdvanced.GetBookmarks((int)personid);

            return(View("Bookmarks", d));
        }
Exemplo n.º 3
0
        public IActionResult LoginPost(string phone, string password)
        {
            if (phone == null || password == null)
            {
                ViewData["ErrorMessage"] = "Phone or password fields were empty.";
                return(View("Login"));
            }

            switch (DbAdvanced.CheckCredentials(phone, password))
            {
            case 'n':
                HttpContext.Session.SetString("Phone", phone);
                Credential cr = DbClient.CredentialCache.Get(phone);
                HttpContext.Session.SetInt32("PersonID", cr.PersonID);
                HttpContext.Session.SetString("Privilegies", ((char)cr.Privilegies).ToString());
                ViewData["LoggedIn"] = true;
                return(RedirectToAction("Explore"));

            case 'p':
                ViewData["ErrorMessage"] = "Password is wrong. Try again.";
                break;

            case 'a':
                ViewData["ErrorMessage"] = $"Account with phone '{phone}' was not found.";
                break;

            case 'b':
                ViewData["ErrorMessage"] = $"Account with phone '{phone}' was permanently banned.";
                break;

            case 'd':
                ViewData["ErrorMessage"] = $"Account with phone '{phone}' was deactivated.";
                break;

            default:
                ViewData["ErrorMessage"] = "Unknown error occured. Try again.";
                break;
            }

            return(View("Login"));
        }
Exemplo n.º 4
0
        public ActionResult FindMatches(int wishid)
        {
            int?personid = HttpContext.Session.GetInt32("PersonID");

            if (personid == null)
            {
                return(new UnauthorizedResult());
            }
            ViewData["LoggedIn"] = true;
            ClientWish wish;

            if (DbClient.ClientWishCache.TryGet(wishid, out wish))
            {
                Dictionary <int, EstateObject> objects = DbAdvanced.FindMatches(wish, 10);
                ViewData["DisableFilter"] = true;
                return(View("Explore", objects));
            }
            else
            {
                return(new NotFoundResult());
            }
        }
Exemplo n.º 5
0
        public ActionResult Explore(int district, string variant, string order, int maxprice)
        {
            if (HttpContext.Session.GetInt32("PersonID") != null)
            {
                ViewData["LoggedIn"] = true;
            }
            if (variant == null)
            {
                return(View("Explore", DbAdvanced.GetEstateObjects()));
            }
            Dictionary <int, EstateObject> result = new Dictionary <int, EstateObject>();

            switch (variant)
            {
            case "h":
                foreach (var i in DbAdvanced.GetHouses(district, maxprice, order))
                {
                    result[i.Key] = i.Value;
                }
                return(View("Explore", result));

            case "f":
                foreach (var i in DbAdvanced.GetFlats(district, maxprice, order))
                {
                    result[i.Key] = i.Value;
                }
                return(View("Explore", result));

            case "l":
                foreach (var i in DbAdvanced.GetLandplots(district, maxprice, order))
                {
                    result[i.Key] = i.Value;
                }
                return(View("Explore", result));

            default:
                return(View("Explore", DbAdvanced.GetEstateObjects(district, maxprice, order)));
            }
        }
Exemplo n.º 6
0
        public ActionResult Signup()
        {
            Person p = new Person {
                Phone       = Request.Form["phone"],
                Email       = Request.Form["email"],
                Name        = Request.Form["name"],
                Surname     = Request.Form["surname"],
                LocationID  = int.Parse(Request.Form["location"]),
                StreetName  = Request.Form["street"],
                HouseNumber = Request.Form["housenumber"],
                RegDate     = DateTime.UtcNow
            };
            short flatnumber;

            if (short.TryParse(Request.Form["flatnumber"], out flatnumber))
            {
                p.FlatNumber = flatnumber;
            }
            var v = p.Validate;

            if (!v.isValid)
            {
                ViewData["ErrorMessage"] = v.Message;
                return(View("Signup"));
            }
            try
            {
                DbAdvanced.CreateAccount(p, Request.Form["password"]);
                ViewData["ErrorMessage"] = "You have successfully created an account. Now log in.";
                return(View("Login"));
            }
            catch (ReferentialException ee)
            {
                ViewData["ErrorMessage"] = ee.ReadableMessage;
                return(View("Signup"));
            }
        }
 public Dictionary <string, string> GetDistrictsOfTown(string town)
 {
     return(DbAdvanced.GetDistrictsOfTown(town));
 }
 public ICollection <string> GetTownsOfRegion(string region)
 {
     return(DbAdvanced.GetTownsOfRegion(region));
 }