Example #1
0
        public ActionResult Login(FormLoginUser luser)
        {
            User user = Models.User.getByEmail(luser.email);

            if (user == null)
            {
                ViewBag.Message = "Email does not exist";
            }
            else
            {
                if (!user.ValidatePassword(luser.password))
                {
                    ViewBag.Message = "Bad password";
                }
                else
                {
                    if (user.admin_flag)
                    {
                        Session[KeysUtils.SessionAdmin()] = user;
                        return(RedirectToAction("Index", "Admin"));
                    }
                    else
                    {
                        Session[KeysUtils.SessionUser()] = user;
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }
            return(View(luser));
        }
        public ActionResult CreateAuction(FormCreateAuction fcAuction)
        {
            User u = (User)Session[KeysUtils.SessionUser()];

            if (u == null)
            {
                u = (User)Session[KeysUtils.SessionAdmin()];
                if (u == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            if (ModelState.IsValid)
            {
                Auction a = Auction.Create(fcAuction, u.user_id);
                a.save();
                ViewBag.Status  = true;
                ViewBag.Message = "Successfuly creaed auction";
            }
            else
            {
                ViewBag.Message = "Invalid request";
            }

            return(View(fcAuction));
        }
Example #3
0
        public ActionResult EditSystemConfig()
        {
            User u = (User)Session[KeysUtils.SessionAdmin()];

            if (u == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(SystemConf.GetSystemConf()));
            }
        }
Example #4
0
        public ActionResult Index()
        {
            User u = (User)Session[KeysUtils.SessionAdmin()];

            if (u == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                List <Auction> list = Auction.getReadyAuctions();
                return(View(list));
            }
        }
Example #5
0
        public ActionResult StartAuction(Guid key)
        {
            User u = (User)Session[KeysUtils.SessionAdmin()];

            if (u == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                Auction auction = Auction.getByKey(key);
                if (auction != null)
                {
                    auction.state         = KeysUtils.AuctionOpened();
                    auction.current_price = auction.starting_price;
                    DateTime t = DateTime.Now;
                    auction.opened = t;
                    auction.closed = t.AddSeconds(auction.duration);

                    auction.saveChanges();
                }
                return(RedirectToAction("Index", "Admin"));
            }
        }
Example #6
0
        public ActionResult EditSystemConfig(SystemConf conf)
        {
            User u = (User)Session[KeysUtils.SessionAdmin()];

            if (u == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    conf.save();
                    ViewBag.Status  = true;
                    ViewBag.Message = "Successfuly edited configuration";
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                    conf            = SystemConf.GetSystemConf();
                }
                return(View(conf));
            }
        }
Example #7
0
 public ActionResult SignOut()
 {
     Session[KeysUtils.SessionUser()]  = null;
     Session[KeysUtils.SessionAdmin()] = null;
     return(RedirectToAction("Index", "Home"));
 }