Пример #1
0
 public ActionResult Index()
 {
     try
     {
         if (Session["ModId"] != null)
         {
             TypeAppDAO   dao  = new TypeAppDAO();
             UserDAO      udao = new UserDAO();
             ModeratorDAO mdao = new ModeratorDAO();
             ViewBag.Mod = mdao.SearchById(int.Parse(Session["ModId"].ToString()));
             User u = udao.SearchById(int.Parse(Session["Id"].ToString()));
             ViewBag.User  = u;
             ViewBag.Type  = new TypeApp();
             ViewBag.Types = dao.List();
             return(View());
         }
         else
         {
             return(RedirectToAction("../Home/Index"));
         }
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Пример #2
0
 public ActionResult Promote(int id)
 {
     try
     {
         if (int.Parse(Session["Id"].ToString()) != id)
         {
             ModeratorDAO dao  = new ModeratorDAO();
             UserDAO      udao = new UserDAO();
             if (dao.SearchByUserId(id) == null)
             {
                 Moderator m = new Moderator();
                 m.UserId = id;
                 dao.Add(m);
                 Moderator mod = dao.SearchByUserId(id);
                 User      u   = udao.SearchById(id);
                 u.ModeratorId = mod.Id;
                 udao.Update();
             }
         }
         return(RedirectToAction("Register"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Пример #3
0
 public ActionResult ProfileView()
 {
     try
     {
         if (Session["ModId"] != null)
         {
             UserDAO        udao = new UserDAO();
             ModeratorDAO   dao  = new ModeratorDAO();
             SellDAO        sdao = new SellDAO();
             ApplicationDAO adao = new ApplicationDAO();
             ViewBag.Mod = dao.SearchById(int.Parse(Session["ModId"].ToString()));
             User u = udao.SearchById(int.Parse(Session["Id"].ToString()));
             ViewBag.NewUser   = udao.GetMonthUsers().Count;
             ViewBag.NewGame   = adao.GetGamesMonth().Count;
             ViewBag.NewSoft   = adao.GetSoftwareMonth().Count;
             ViewBag.NewMob    = adao.GetMobileMonth().Count;
             ViewBag.SaleCount = sdao.Get7DaysSells();
             ViewBag.User      = u;
             return(View());
         }
         else
         {
             return(RedirectToAction("../Home/Index"));
         }
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Пример #4
0
 public IHttpActionResult Put(Moderator todo)
 {
     if (ModeratorDAO.Update(todo))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Пример #5
0
        public IHttpActionResult Delete(int id)
        {
            if (ModeratorDAO.Delete(id))
            {
                return(Ok());
            }

            return(BadRequest());
        }
        public ModeratorController()
        {
            string connection = ConfigurationManager.ConnectionStrings["dataSource"].ConnectionString;
            string logPathDAL = ConfigurationManager.AppSettings["LogPathDAL"];
            string logPathMVC = ConfigurationManager.AppSettings["LogPathMVC"];
            string logPathBLL = ConfigurationManager.AppSettings["LogPathBLL"];

            _moderatorDAO = new ModeratorDAO(connection, logPathDAL);
            _moderatorBLO = new ModeratorBLO(logPathBLL);
            _logger       = new LoggerMVC(logPathMVC, connection);
        }
Пример #7
0
 public PartialViewResult GenreIndex()
 {
     if (Session["ModId"] != null)
     {
         GenreDAO     dao  = new GenreDAO();
         UserDAO      udao = new UserDAO();
         ModeratorDAO mdao = new ModeratorDAO();
         ViewBag.Mod = mdao.SearchById(int.Parse(Session["ModId"].ToString()));
         User u = udao.SearchById(int.Parse(Session["Id"].ToString()));
         ViewBag.User   = u;
         ViewBag.Genre  = new Genre();
         ViewBag.Genres = dao.List();
         return(PartialView());
     }
     else
     {
         return(PartialView());
     }
 }
Пример #8
0
 public ActionResult Login(User user)
 {
     try
     {
         UserDAO dao    = new UserDAO();
         User    u      = dao.Login(user);
         var     result = "";
         if (u != null)
         {
             Session["Id"]       = u.Id;
             Session["Username"] = u.Username;
             if (u.DeveloperId != null)
             {
                 DeveloperDAO ddao = new DeveloperDAO();
                 Developer    d    = ddao.SearchById(int.Parse(u.DeveloperId.ToString()));
                 Session["DevId"] = d.Id;
             }
             if (u.ModeratorId != null)
             {
                 ModeratorDAO mdao = new ModeratorDAO();
                 Moderator    m    = mdao.SearchById(int.Parse(u.ModeratorId.ToString()));
                 Session["ModId"] = m.Id;
             }
             result = "Logged In";
             return(Json(result, JsonRequestBehavior.AllowGet));
             //return RedirectToAction("../Home/Index");
         }
         result = "An error occurred. Try again";
         return(Json(result, JsonRequestBehavior.AllowGet));
         //return RedirectToAction("../Home/Index");
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Пример #9
0
 public ActionResult Demote(int id)
 {
     try
     {
         if (int.Parse(Session["Id"].ToString()) != id)
         {
             ModeratorDAO dao  = new ModeratorDAO();
             UserDAO      udao = new UserDAO();
             if (dao.SearchByUserId(id) != null)
             {
                 User      u = udao.SearchById(id);
                 Moderator m = dao.SearchByUserId(id);
                 u.ModeratorId = null;
                 udao.Update();
                 dao.Remove(m);
             }
         }
         return(RedirectToAction("Register"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Пример #10
0
 public Moderator Get(int id)
 {
     return(ModeratorDAO.Get(id));
 }
Пример #11
0
 public Moderator Post(Moderator todo)
 {
     return(ModeratorDAO.Insert(todo));
 }
Пример #12
0
 public List <Moderator> GetAll()
 {
     return(ModeratorDAO.Query());
 }