コード例 #1
0
        public ActionResult Verify(string Username, string Password)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    Tbl_LoginBusinessModelLayers tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();

                    BusinessModelLayer.Tbl_LoginSingle tbl_login = tbl_loginBusinessModelLayers.GetAllTbl_Logins().FirstOrDefault(x => x.Username == Username && x.Password == Password);

                    if (tbl_login != null)
                    {
                        UpdateModel <Tbl_LoginSingle>(tbl_login);
                        if (ModelState.IsValid)
                        {
                            FormsAuthentication.SetAuthCookie(tbl_login.Username, false);
                            return(RedirectToAction("List", "Orders"));
                        }
                    }
                    return(View("Error"));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public ActionResult Edit_Post(string Username)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    Tbl_LoginBusinessModelLayers tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();

                    BusinessModelLayer.Tbl_LoginSingle tbl_login = tbl_loginBusinessModelLayers.GetAllTbl_Logins().Single(x => x.Username == Username);


                    UpdateModel <Tbl_LoginSingle>(tbl_login);
                    if (ModelState.IsValid)
                    {
                        //mm
                        tbl_loginBusinessModelLayers.UpdateTbl_Login(tbl_login);
                        return(RedirectToAction("List"));
                    }

                    return(View(tbl_login));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
 public ActionResult Create_Post()
 {
     try     // handle exogenous exceptions
     {
         try // log all exceptions
         {
             Tbl_LoginBusinessModelLayers       tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();
             BusinessModelLayer.Tbl_LoginSingle tbl_login = new BusinessModelLayer.Tbl_LoginSingle();
             TryUpdateModel(tbl_login);
             if (ModelState.IsValid)
             {
                 //mm
                 tbl_loginBusinessModelLayers.AddTbl_Login(tbl_login);
                 return(RedirectToAction("List"));
             }
             else
             {
                 return(View());
             }
         }
         catch (Exception ex)
         {
             BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
             exlog.SendExcepToDB(ex);
             throw;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #4
0
        //END - readBy
        //BEGIN - create
        public void AddTbl_Login(Tbl_LoginSingle tbl_login)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        SqlCommand cmd = new SqlCommand("spAddTbl_Login", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        };
                        SqlParameter paramUsername = new SqlParameter
                        {
                            ParameterName = "@Username",
                            Value         = tbl_login.Username
                        };
                        cmd.Parameters.Add(paramUsername);

                        SqlParameter paramPassword = new SqlParameter
                        {
                            ParameterName = "@Password",
                            Value         = tbl_login.Password
                        };
                        cmd.Parameters.Add(paramPassword);

                        SqlParameter paramRoles = new SqlParameter
                        {
                            ParameterName = "@Roles",
                            Value         = tbl_login.Roles
                        };
                        cmd.Parameters.Add(paramRoles);

                        SqlParameter paramActiveStatus = new SqlParameter
                        {
                            ParameterName = "@ActiveStatus",
                            Value         = tbl_login.ActiveStatus
                        };
                        cmd.Parameters.Add(paramActiveStatus);

                        con.Open();
                        cmd.ExecuteNonQuery();
                        cmd.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    //errResult = "A Technical Error occurred, Please visit after some time.";
                    throw;
                }
            }
            catch (Exception fx)
            {
                errResult = fx.Message.ToString();
                throw;
            }
        }
コード例 #5
0
        //BEGIN - readBy
        public Tbl_LoginSingle GetTbl_LoginData(string Username)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    Tbl_LoginSingle tbl_login = new Tbl_LoginSingle();
                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        string sqlQuery = "SELECT * FROM [tbl_Login] WHERE Username= '******'";

                        using (SqlCommand cmd = new SqlCommand(sqlQuery, con))
                        {
                            con.Open();
                            SqlDataReader rdr = cmd.ExecuteReader();
                            while (rdr.Read())
                            {
                                //tbl_login.Username = (string)rdr["Username"];
                                tbl_login.Username = rdr["Username"] == DBNull.Value ? "" : (string)rdr["Username"];

                                //tbl_login.Password = (string)rdr["Password"];
                                tbl_login.Password = rdr["Password"] == DBNull.Value ? "" : (string)rdr["Password"];

                                //tbl_login.Roles = (string)rdr["Roles"];
                                tbl_login.Roles = rdr["Roles"] == DBNull.Value ? "" : (string)rdr["Roles"];


                                //tbl_login.ActiveStatus = (bool)rdr["ActiveStatus"];
                                tbl_login.ActiveStatus = rdr["ActiveStatus"] == DBNull.Value ? false : (bool)rdr["ActiveStatus"];

                                //EXAMPLES:
                                //employee.EmployeeId = Convert.ToInt32(rdr["EmployeeID"]);
                                //employee.Name = rdr["Name"].ToString();
                                //employee.Gender = rdr["Gender"].ToString();
                                //employee.Salary = (decimal)rdr["Salary"];
                                //employee.City = rdr["City"].ToString();
                                //employee.IsPermanent = (bool)rdr["IsPermanent"];
                                //employee.DateOfBirth = Convert.ToDateTime(rdr["DateOfBirth"]);
                            }
                        }
                    }
                    return(tbl_login);
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    //errResult = "A Technical Error occurred, Please visit after some time.";
                    throw;
                }
            }
            catch (Exception fx)
            {
                errResult = fx.Message.ToString();
                throw;
            }
        }
コード例 #6
0
ファイル: UsersRoleProvider.cs プロジェクト: f10ydmi11s/Demo
        public override string[] GetRolesForUser(string username)
        {
            //using (EmployeeDBContext context = new EmployeeDBContext())
            //{
            //var userRoles = (from user in context.Users
            //                 join roleMapping in context.UserRolesMappings
            //                 on user.ID equals roleMapping.UserID
            //                 join role in context.RoleMasters
            //                 on roleMapping.RoleID equals role.ID
            //                 where user.UserName == username
            //                 select role.RollName).ToArray();
            Tbl_LoginBusinessModelLayers tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();

            BusinessModelLayer.Tbl_LoginSingle tbl_login = tbl_loginBusinessModelLayers.GetAllTbl_Logins().FirstOrDefault(x => x.Username == username);
            var userRoles = "User".Split(',').ToArray();

            if (tbl_login != null)
            {
                userRoles = tbl_login.Roles.Split(',').ToArray();
            }
            return(userRoles);
            //}
        }
コード例 #7
0
        public ActionResult Details(string Username)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    Tbl_LoginBusinessModelLayers tbl_loginBusinessModelLayers = new Tbl_LoginBusinessModelLayers();

                    BusinessModelLayer.Tbl_LoginSingle tbl_login = tbl_loginBusinessModelLayers.GetAllTbl_Logins().FirstOrDefault(x => x.Username == Username);

                    return(View(tbl_login));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #8
0
        //END - delete


        //BEGIN - read
        public List <Tbl_LoginSingle> GetAllTbl_Logins()
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    List <Tbl_LoginSingle> tbl_logins = new List <Tbl_LoginSingle>();

                    using (SqlConnection con = new SqlConnection(connectionString))
                    {
                        SqlCommand cmd = new SqlCommand("spGetAllTbl_Login", con)
                        {
                            CommandType = CommandType.StoredProcedure
                        };

                        con.Open();

                        SqlDataReader rdr = cmd.ExecuteReader();

                        while (rdr.Read())
                        {
                            Tbl_LoginSingle tbl_login = new Tbl_LoginSingle
                            {
                                // EXAMPLES:
                                //EmployeeId = Convert.ToInt32(rdr["EmployeeId"]),
                                //Name = rdr["Name"].ToString(),
                                //IsPermanent = (bool)rdr["IsPermanent"],
                                //Salary = Convert.ToDecimal(rdr["Salary"]),
                                //DateOfBirth = Convert.ToDateTime(rdr["DateOfBirth"])

                                //Username = (string)rdr["Username"]
                                Username = rdr["Username"] == DBNull.Value ? "" : (string)rdr["Username"]
                                           //,Password = (string)rdr["Password"]
                                ,
                                Password = rdr["Password"] == DBNull.Value ? "" : (string)rdr["Password"]
                                           //,Roles = (string)rdr["Roles"]
                                ,
                                Roles = rdr["Roles"] == DBNull.Value ? "" : (string)rdr["Roles"]

                                        //,ActiveStatus = (bool)rdr["ActiveStatus"]
                                ,
                                ActiveStatus = rdr["ActiveStatus"] == DBNull.Value ? false : (bool)rdr["ActiveStatus"]
                            };
                            tbl_logins.Add(tbl_login);
                        }
                        con.Close();
                        cmd.Dispose();
                    }
                    return(tbl_logins);
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    //errResult = "A Technical Error occurred, Please visit after some time.";
                    throw;
                }
            }
            catch (Exception fx)
            {
                errResult = fx.Message.ToString();
                throw;
            }
        }