Ejemplo n.º 1
0
        internal string adminLogin(AdminModel objReq)
        {
            string i = "0";
            try
            {
                using (var db = new WizzDataContext())
                {
                    tblUser admin = new tblUser();
                    if (objReq != null)
                    {
                        admin = db.tblUsers.Where(e => e.userEmail == objReq.email && e.registerType == 1).FirstOrDefault();
                        if (admin != null)
                        {
                            if (objReq.password.ToLower() == admin.password)
                            {

                                i = "loggedIn";
                                CurrentUser user = new CurrentUser()
                                {
                                    PkUserId = Convert.ToString(admin.pkUserId),
                                    Email = admin.userEmail,
                                    isActive = Convert.ToString(admin.isActive),
                                    usertype = Convert.ToString(admin.registerType),
                                };
                                string json = JsonConvert.SerializeObject(user);
                                FormsAuthentication.SetAuthCookie(json, true);

                            }
                            else
                            {
                                i = "Invalid password !";
                            }
                        }
                        else
                        {
                            i = "The Email Id is not registered with us !";
                        }
                    }
                    return i;
                }
            }
            catch (Exception ex)
            {
                i = ex.ToString();
                return i;
            }
        }
        public string Login(AdminModel objReq)
        {

            AdminMethods obj = new AdminMethods();
            return obj.adminLogin(objReq);
        }