Beispiel #1
0
        // GET: Admin
        public ActionResult Index()
        {
            if (Session["userId"] == null || Session["userId"].ToString() == "")
            {
                return(RedirectToAction("Index", "Home"));
            }
            //return View();
            //string EmailId = Session["userId"].ToString();

            ModelContext context = new ModelContext();

            List <User>       users = context.Users.ToList();
            List <UserDetail> list  = new List <UserDetail>();

            UserDetail userDetail;

            foreach (User user in users)
            {
                userDetail = new UserDetail();
                Address address = context.Addresses.SingleOrDefault(m => m.AddressId == user.AddressId);
                userDetail.EmailId = user.EmailId;
                userDetail.Name    = user.Name;
                userDetail.Age     = user.Age;
                userDetail.Gender  = (Gender)user.Gennder;

                if (user.RoleId == 2)
                {
                    userDetail.RoleName = RoleType.User;
                }
                else if (user.RoleId == 3)
                {
                    userDetail.RoleName = RoleType.Vendor;
                }


                userDetail.UserStatus = user.UserStatus;

                userDetail.AddressLine1 = address.AddressLine1;
                userDetail.AddressLine2 = address.AddressLine2;
                userDetail.City         = address.City;
                userDetail.State        = address.State;
                userDetail.Country      = address.Country;
                userDetail.PinCode      = address.PinCode;

                list.Add(userDetail);
            }
            UserServiceCourse userServiceCourse = new UserServiceCourse();

            userServiceCourse.Courses     = context.Courses.ToList();
            userServiceCourse.Services    = context.Services.ToList();
            userServiceCourse.UserDetails = list;

            return(View(userServiceCourse));

            //return Content("check" + EmailId);
        }
Beispiel #2
0
        public ActionResult AllSubscriber()
        {
            if (Session["userId"] == null || Session["userId"].ToString() == "")
            {
                return(RedirectToAction("Index", "Home"));
            }
            ModelContext db = new ModelContext();
            //List<User> users = db.Users.Where(a => a.UserRole == RoleType.User).ToList();
            List <User> users = db.Users.Where(a => a.RoleId == 2).ToList();

            UserDetail        userDetail;
            List <UserDetail> list = new List <UserDetail>();

            foreach (User user in users)
            {
                userDetail = new UserDetail();
                Address address = db.Addresses.SingleOrDefault(m => m.AddressId == user.AddressId);
                userDetail.EmailId = user.EmailId;
                userDetail.Name    = user.Name;
                userDetail.Age     = user.Age;
                userDetail.Gender  = (Gender)user.Gennder;
                if (user.RoleId == 2)
                {
                    userDetail.RoleName = RoleType.User;
                }
                else if (user.RoleId == 3)
                {
                    userDetail.RoleName = RoleType.Vendor;
                }


                //userDetail.UserStatus = user.UserStatus;

                userDetail.AddressLine1 = address.AddressLine1;
                userDetail.AddressLine2 = address.AddressLine2;
                userDetail.City         = address.City;
                userDetail.State        = address.State;
                userDetail.Country      = address.Country;
                userDetail.PinCode      = address.PinCode;
                list.Add(userDetail);
            }


            UserServiceCourse all = new UserServiceCourse();

            all.Courses     = db.Courses.ToList();
            all.Services    = db.Services.ToList();
            all.UserDetails = list;

            return(View("Index", all));
        }