示例#1
0
        private LoginDetails ValidateUser(string uname, string psw)
        {
            Accountcontext accountContext = new Accountcontext();
            Account        account        = accountContext.Accounts.FirstOrDefault(acc => (acc.FirstName == uname) && (acc.Empid == psw));
            LoginDetails   obj            = new LoginDetails();

            obj.IsAuthUser = false;
            try
            {
                Accountcontext accountContext1 = new Accountcontext();
                Account        account1        = accountContext.Accounts.FirstOrDefault(acc => (acc.FirstName == uname) && (acc.Empid == psw));
                if (account != null)
                {
                    obj.UserId     = account1.Personid;
                    obj.UserName   = account1.FirstName;
                    obj.Role       = account1.Type;
                    obj.IsAuthUser = true;
                }
            }
            catch (Exception ex)
            {
                obj.IsAuthUser = false;
                Response.Write("<script>alert('" + ex.Message.Replace("\'", " ") + "')</script>");
            }
            return(obj);
        }
示例#2
0
 public ActionResult AddorEdit(Account newacc)
 {
     using (Accountcontext acc = new Accountcontext())
     {
         try
         {
             newacc.Type = "Sale";
             if (newacc.Personid == 0)
             {
                 acc.Accounts.Add(newacc);
                 acc.SaveChanges();
                 return(RedirectToAction("Details", "Account"));
             }
             else
             {
                 acc.Entry(newacc).State = EntityState.Modified;
                 acc.SaveChanges();
                 return(RedirectToAction("Details", "Account"));
             }
         }
         catch (Exception ex)
         {
             return(Content("<script>alert('" + ex.Message.Replace("\'", " ") + "')</script>"));
             // HttpContext.Response.Write("<script>alert('" + ex.Message.Replace("\'", " ") + "')</script>");
             //return RedirectToAction("Details", "Account");
         }
     }
 }
示例#3
0
        // GET: Account

        public ActionResult Details()
        {
            if (Session["id"] == null || (string)Session["Type"] != "Admin")
            {
                return(RedirectToAction("Login", "Login"));
            }
            Accountcontext accountContext = new Accountcontext();
            var            account        = accountContext.Accounts.Where(acc => acc.Type != "Admin").ToList();

            //var account = (from Account in accountContext.Accounts select Account).ToList();
            return(View(account));
        }
        // GET: Lead
        public ActionResult LeadDetails()
        {
            if (Session["id"] == null || (string)Session["Type"] != "Admin")
            {
                return(RedirectToAction("Login", "Login"));
            }
            Accountcontext accountContext = new Accountcontext();
            var            Employeeid     = accountContext.Accounts.Where(acc => acc.Type != "Admin").Select(acc => acc.Empid).ToList();
            Leadcontext    leadContext    = new Leadcontext();

            ViewBag.Employeeid = Employeeid;
            var account = leadContext.Leads.ToList();

            return(View(account));
        }
        // GET: Assign
        public ActionResult AssignLeads()
        {
            if (Session["id"] == null || (string)Session["Type"] == "Admin")
            {
                return(Content("<script>alert('" + "You Have no Authorize Access to This page" + "');window.location='../Home/Index';</script>"));
                //return RedirectToAction("Login", "Login");
            }
            Accountcontext accountContext = new Accountcontext();
            int            id             = (int)Session["id"];
            var            Employeeid     = accountContext.Accounts.Where(acc => acc.Personid == id).Select(acc => acc.Empid).FirstOrDefault();
            Leadcontext    leadContext    = new Leadcontext();

            ViewBag.Employeeid = Employeeid;
            var account = leadContext.Leads.Where(ld => ld.Empid == Employeeid.ToString()).ToList();

            return(View(account));
        }
示例#6
0
 public ActionResult Delete(int Personid)
 {
     using (Accountcontext acc = new Accountcontext())
     {
         try
         {
             Account person = acc.Accounts.Where(x => x.Personid == Personid).FirstOrDefault <Account>();
             acc.Accounts.Remove(person);
             acc.SaveChanges();
             return(RedirectToAction("Details", "Account"));
         }
         catch (Exception ex)
         {
             return(Content("<script>alert('" + ex.Message.Replace("\'", " ") + "')</script>"));
             // HttpContext.Response.Write("<script>alert('" + ex.Message.Replace("\'", " ") + "')</script>");
             //return RedirectToAction("Details", "Account");
         }
     }
 }
示例#7
0
 public AccountsController(Accountcontext context)
 {
     _context = context;
 }