public string HowIsYourDatabase()
 {
     try
     {
         var logs = new DcDataContext().LogSet_Select().Take(1).FirstOrDefault().Id;
         return("Its healthy :)");
     }
     catch
     {
         return("Its DOWN");
     }
 }
Exemple #2
0
 public LoginResult Login(string Username, string Password)
 {
     try
     {
         var loginResult = new DcDataContext().User_Login(Username, Password).FirstOrDefault();
         return(new LoginResult {
             Username = Username, Success = Convert.ToBoolean(loginResult.Success), Fullname = loginResult.Fullname, IsAdmin = Convert.ToBoolean(loginResult.IsAdmin)
         });
     }
     catch
     {
         return(new LoginResult {
             Success = false, Fullname = null, Username = Username, IsAdmin = false
         });
     }
 }
        public ActionResult In(string Username, string Password)
        {
            DcDataContext dc = new DcDataContext();

            if (dc.Admin_Login(Username, Password).Count() > 0)
            {
                Session["Username"] = Username;
                Session["Password"] = Password;
            }
            else
            {
                ViewBag.Message = "Invalid username or password";
                return(View());
            }
            return(RedirectToAction("Index", "Admin"));
        }
Exemple #4
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            bool CanAccess = true;

            try
            {
                DcDataContext dc = new DcDataContext();
                if (dc.Admin_Login(filterContext.HttpContext.Session["Username"].ToString(), filterContext.HttpContext.Session["Password"].ToString()).Count() > 0)
                {
                    CanAccess = true;
                }
            }
            catch
            {
                CanAccess = false;
            }
            if (!CanAccess)
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Exemple #5
0
        public List <MenuItem> Select()
        {
            List <MenuItem> Output = new List <MenuItem>();

            v_Group[] Data       = new DcDataContext().v_Groups.OrderBy(x => x.Serial).ToArray();
            int       TotalItems = Data.Length;

            v_Group[] PrimaryTable   = new v_Group[TotalItems];
            v_Group[] SecondaryTable = new v_Group[TotalItems];
            int       Index          = 0;

            while (Index < TotalItems)
            {
                int a = 0;
                while (a < Data.Length - Index)
                {
                    PrimaryTable[a] = Data[Index + a];
                    a++;
                }
                int b = Index + 0;
                while (b < TotalItems)
                {
                    Data[b] = null;
                    b++;
                }
                v_Group CurrentItem = PrimaryTable[0];
                int     c           = 0;
                foreach (var item in PrimaryTable)
                {
                    if (item != null)
                    {
                        if (item.ParentId == CurrentItem.Id || item.Id == CurrentItem.Id)
                        {
                        }
                        else
                        {
                            SecondaryTable[c] = item;
                            PrimaryTable[c]   = null;
                        }
                        c++;
                    }
                }
                int d = Index + 0;
                int e = 0;
                foreach (var item in PrimaryTable)
                {
                    if (item != null)
                    {
                        Data[d] = PrimaryTable[e];
                        d++;
                        PrimaryTable[e] = null;
                    }
                    e++;
                }
                int f = 0;

                foreach (var item in SecondaryTable)
                {
                    if (item != null)
                    {
                        Data[d] = SecondaryTable[f];
                        d++;
                        SecondaryTable[f] = null;
                    }
                    f++;
                }
                a = b = c = d = e = f = 0;

                Index++;
            }

            int z = 0;

            foreach (var v in Data)
            {
                bool    IsCounting          = true;
                v_Group currentCountingItem = v;
                int     depth = 0;
                while (IsCounting)
                {
                    if (currentCountingItem.ParentId != null)
                    {
                        currentCountingItem = Data.Where(k => k.Id == currentCountingItem.ParentId).First();
                        depth++;
                    }
                    else
                    {
                        IsCounting = false;
                    }
                }
                Output.Add(new MenuItem {
                    Index = z, Depth = depth, OtherProps = v
                });
                z++;
            }
            return(Output);
        }