Ejemplo n.º 1
0
 public static string getCategoryName(int?categoryID)
 {
     using (DataDataContext db = new DataDataContext())
     {
         var category = db.Categories.Where(n => n.Id == categoryID).SingleOrDefault();
         if (category != null)
         {
             return(category.Name);
         }
         else
         {
             return("Not Found");
         }
     }
 }
Ejemplo n.º 2
0
 public static bool checkUserExists(string UserName)
 {
     using (DataDataContext db = new DataDataContext())
     {
         var user = db.Users.Where(n => n.Name == UserName).SingleOrDefault();
         if (user != null)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 3
0
 public static string getUserName(int?UserID)
 {
     using (DataDataContext db = new DataDataContext())
     {
         var user = db.Users.Where(n => n.Id == UserID).FirstOrDefault();
         if (user != null)
         {
             return(user.Name);
         }
         else
         {
             return("default");
         }
     }
 }
Ejemplo n.º 4
0
 public static int?getUserRole(int?UserID)
 {
     using (DataDataContext db = new DataDataContext())
     {
         var user = db.Users.Where(n => n.Id == UserID).FirstOrDefault();
         if (user != null)
         {
             return(user.Role);
         }
         else
         {
             return(null);
         }
     }
 }
Ejemplo n.º 5
0
 public static int getUserID(string UserName)
 {
     using (DataDataContext db = new DataDataContext())
     {
         var user = db.Users.Where(n => n.Name == UserName).FirstOrDefault();
         if (user != null)
         {
             return(user.Id);
         }
         else
         {
             return(0);
         }
     }
 }
Ejemplo n.º 6
0
 protected void lnkForgotPassword_Click(object sender, EventArgs e)
 {
     using (DataDataContext db = new DataDataContext())
     {
         var user = db.Users.Where(n => n.Name == txtUserName.Text).SingleOrDefault();
         if (user == null)
         {
             ClientScript.RegisterClientScriptBlock(this.GetType(), "User", "alert('Username incorrect!')", true);
         }
         else
         {
             user.Reset_Request = true;
             db.SubmitChanges();
             ClientScript.RegisterClientScriptBlock(this.GetType(), "User", "alert('Request to admin have been sent!')", true);
         }
     }
 }
Ejemplo n.º 7
0
        private bool AuthorisedUser(string userName, string password)
        {
            var ensdPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1");

            using (DataDataContext db = new DataDataContext())
            {
                var user = db.Users.Where(n => n.Name == userName && n.Password == ensdPassword && n.Active == true).SingleOrDefault();
                if (user != null)
                {
                    Session["LoginId"] = user.Id;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
 public void ProcessRequest(HttpContext context)
 {
     using (DataDataContext db = new DataDataContext())
     {
         var    postID = Convert.ToInt32(context.Request.QueryString["PostID"]);
         string Size   = context.Request.QueryString["Size"].ToString().ToLower();
         var    post   = db.Posts.Where(n => n.Id == postID).SingleOrDefault();
         if (post != null)
         {
             var img      = GlobalMethods.BinaryToImage(post.Image.ToArray());
             var imgArray = GetBytesFromImage(generateImage(img, Size));
             context.Response.ContentType = "image/jpg";
             context.Response.OutputStream.Write(imgArray, 0, imgArray.Length);
             context.Response.Flush();
             context.Response.End();
         }
     }
 }