Esempio n. 1
0
        public JsonResult GetSearchValue(string search)
        {
            DB53Entities db = new DB53Entities();

            List <Person> allsearch = db.People.Where(x => x.FirstName.Contains(search)).Select(x => new Person
            {
                Id        = x.Id,
                FirstName = x.FirstName
            }).ToList();

            return(new JsonResult {
                Data = allsearch, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Esempio n. 2
0
        public ActionResult Login(Login entity)
        {
            using (DB53Entities db = new DB53Entities())
            {
                //fetche the data of user on the basis of inserted email
                Login user = db.Logins.FirstOrDefault(u => u.Email == (entity.Email));

                //if entered email is not bound to any user then object will be null
                if (user == null)
                {
                    TempData["ErrorMSG"] = "object not found";

                    return(View(entity));
                }
                //if we are here then it mean we sucsessfuly retrived the data
                //now we compare password
                int a = entity.Password.Count();
                if (user.Password.Substring(0, a) != entity.Password)
                {
                    //TempData["ErrorMSG"] = "Password not matched";
                    ModelState.AddModelError("Password", "Password doesnot match.");
                    return(View(entity));
                }

                else
                {
                    if (user.Password.Substring(0, a) == entity.Password)
                    {
                        if (user.Discriminator.Substring(0, 5) == "Admin")
                        {
                            return(RedirectToAction("Admindashboard", "People"));
                        }
                        else if (user.Discriminator.Substring(0, 5) == "Staff")
                        {
                            Staff staffuser = db.Staffs.FirstOrDefault(u => u.Staff_Id == (user.Login_Id));
                            if (staffuser != null)
                            {
                                return(RedirectToAction("StaffAbout", "Staffs"));
                            }
                        }
                        else
                        {
                            return(RedirectToAction("Admindashboard", "People"));
                        }
                    }
                    return(View());
                }
            }
        }
Esempio n. 3
0
        public ActionResult SignUp([Bind(Include = "FirstName,LastName,Contact,Email,Address,Country,DateOfBirth,Gender,Discriminator,Password,ConfirmPassword ")] User userrr)
        {
            using (DB53Entities db = new DB53Entities())
            {
                Person persuser = db.People.FirstOrDefault(u => u.Email == (userrr.Email));
                if (userrr.Discriminator == "Admin")
                {
                    Login oldlog = db.Logins.FirstOrDefault(u => u.Discriminator == userrr.Discriminator);
                    if (oldlog != null)
                    {
                        ModelState.AddModelError("Discriminator", "Admin is alredy present. There can be only one Admin.");
                        return(View(userrr));
                    }
                }
                if (persuser == null)
                {
                    Person pers = new Person();
                    pers.Address     = userrr.Address;
                    pers.Contact     = userrr.Contact;
                    pers.Country     = userrr.Country;
                    pers.DateOfBirth = userrr.DateOfBirth;
                    pers.Email       = userrr.Email;
                    pers.FirstName   = userrr.FirstName;
                    pers.LastName    = userrr.LastName;
                    pers.Gender      = userrr.Gender;

                    db.People.Add(pers);
                    db.SaveChanges();
                    Person user = db.People.FirstOrDefault(newuser => newuser.Email == (userrr.Email));

                    Login newlog = new Login();
                    newlog.Login_Id      = user.Id;
                    newlog.Email         = userrr.Email;
                    newlog.Password      = userrr.Password;
                    newlog.Discriminator = userrr.Discriminator;
                    db.Logins.Add(newlog);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "People"));
                }
                else
                {
                    return(View());
                }
            }
        }