Beispiel #1
0
        public ActionResult Create([Bind(Include = "Id,FullName,Post,Age,Qualification,Experience")] Interview interview)
        {
            if (ModelState.IsValid)
            {
                db.Interviews.Add(interview);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(interview));
        }
        public ActionResult Create([Bind(Include = "ID,Name,BirthDate,Qualification,Grade,Center,Governorate,Address,Weight,Height,FatherJob,Type,Fitness,GeneralLook,CulturalLevel,TransportationOpinion,TrainingStaffOpinion,AttendanceDay")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Student.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
        public async Task UserService_GetUsersAsync_Returns_Correct_Users()
        {
            //assemble
            var contextOptions = new DbContextOptionsBuilder <InterviewContext>()
                                 .UseInMemoryDatabase("correct-users-returned")
                                 .Options;
            var user = new User
            {
                Id        = Guid.NewGuid(),
                CreatedOn = DateTime.Now,
                Email     = "*****@*****.**",
                FirstName = "tester",
                LastName  = "test"
            };

            using var context = new InterviewContext(contextOptions);
            context.Users.Add(user);
            context.SaveChanges();
            var service = new UserService(context);

            //act
            var users = await service.GetUsersAsync();

            //assert
            Assert.IsNotNull(users.FirstOrDefault(u => u.Id == user.Id));
        }
        public async Task UserService_GetUsersAsync_Returns_Correct_Number_Of_Users()
        {
            //assemble
            var contextOptions = new DbContextOptionsBuilder <InterviewContext>()
                                 .UseInMemoryDatabase("correct-number-of-users")
                                 .Options;

            var user = new User
            {
                Id        = Guid.NewGuid(),
                CreatedOn = DateTime.Now,
                Email     = "*****@*****.**",
                FirstName = "tester",
                LastName  = "test"
            };

            using var context = new InterviewContext(contextOptions);
            context.Users.Add(user);
            context.SaveChanges();
            var service = new UserService(context);

            //act
            var users = await service.GetUsersAsync();

            //assert
            Assert.AreEqual(users.Count(), 1);
        }
Beispiel #5
0
        public static void Seed(this InterviewContext context)
        {
            AddUser(new User {
                Id = new Guid("844e71eb-684b-466e-af4d-1a7b86d4f5b6"), FirstName = "Dick", LastName = "Richard", CreatedOn = new DateTime(1968, 1, 1), Email = "*****@*****.**"
            }, context);
            AddUser(new User {
                Id = new Guid("59efd189-8306-41d0-a3fc-381d6fb0adfe"), FirstName = "Rocky", LastName = "Balboa", CreatedOn = new DateTime(2016, 3, 1), Email = "*****@*****.**"
            }, context);
            AddUser(new User {
                Id = new Guid("5293847f-24b7-47f9-8ca0-596dbe1777d6"), FirstName = "Johnny", LastName = "Cash", CreatedOn = new DateTime(1989, 1, 1), Email = "*****@*****.**"
            }, context);
            AddUser(new User {
                Id = new Guid("682131e0-bfcd-4d7f-99a8-9408a64ce825"), FirstName = "Georges", LastName = "Washington", CreatedOn = new DateTime(1796, 1, 1), Email = "*****@*****.**"
            }, context);
            AddUser(new User {
                Id = new Guid("94c74f99-427a-43d1-a822-cf0fe25d6834"), FirstName = "Arnold", LastName = "Schwarzenegger", CreatedOn = new DateTime(1796, 1, 1), Email = "*****@*****.**"
            }, context);
            AddUser(new User {
                Id = new Guid("10caa521-18ef-425a-ba3a-d133651f6c3b"), FirstName = "Donald", LastName = "Trump", CreatedOn = new DateTime(2016, 2, 1), Email = "*****@*****.**"
            }, context);

            foreach (var index in Enumerable.Range(1, 100))
            {
                AddUser(new User {
                    Id = Guid.NewGuid(), FirstName = $"Test-{index}", LastName = "Tester", CreatedOn = DateTime.Now, Email = $"test{index}"
                }, context);
            }

            context.SaveChanges();
        }
Beispiel #6
0
        public void UpdateConnectionId(string username)
        {
            var _connectionId = Context.ConnectionId;

            var _user = db.USERS
                        .Where(u => u.USERNAME == username)
                        .FirstOrDefault();

            //_user.CONNECTIONID = Context.ConnectionId;
            db.SaveChanges();
        }
        public ActionResult Logout()
        {
            //Logout from DB
            var user = (USER)Session["user"];

            user = db.USERS
                   .Where(u => u.USERNAME == user.USERNAME)
                   .FirstOrDefault();

            //user.CONNECTIONID = null;
            db.SaveChanges();

            //Remove From Session
            Session["user"] = null;
            //Redirect To LoginPage
            return(RedirectToAction("Login", "Auth"));
        }
Beispiel #8
0
        public ActionResult Rate(FormCollection data)
        {
            //Get Form Parameters
            int    ID   = int.Parse(data["StudentID"]);
            string user = data["user"].ToString();

            Student student = db.Student.Where(s => s.StudentID == ID).FirstOrDefault();

            if (user == "transOpinionSec")
            {
                int TransportationOpinion = int.Parse(data["TransportationOpinion"]);
                student.TransportationOpinion = TransportationOpinion;
                db.SaveChanges();
                return(Json("تم الحفظ"));
            }
            else
            {
                int CulturalLevel        = int.Parse(data["CulturalLevel"]);
                int GeneralLook          = int.Parse(data["GeneralLook"]);
                int TrainingStaffOpinion = int.Parse(data["TrainingStaffOpinion"]);
                if (user == "user1OpinionSec")
                {
                    student.CulturalLevel        = CulturalLevel;
                    student.GeneralLook          = GeneralLook;
                    student.TrainingStaffOpinion = TrainingStaffOpinion;
                    db.SaveChanges();
                    return(Json("تم الحفظ"));
                }
                if (user == "user2OpinionSec")
                {
                    student.CulturalLevel2        = CulturalLevel;
                    student.GeneralLook2          = GeneralLook;
                    student.TrainingStaffOpinion2 = TrainingStaffOpinion;
                    db.SaveChanges();
                    return(Json("تم الحفظ"));
                }
                if (user == "user3OpinionSec")
                {
                    student.CulturalLevel3        = CulturalLevel;
                    student.GeneralLook3          = GeneralLook;
                    student.TrainingStaffOpinion3 = TrainingStaffOpinion;
                    db.SaveChanges();
                    return(Json("تم الحفظ"));
                }
                if (user == "user4OpinionSec")
                {
                    student.CulturalLevel4        = CulturalLevel;
                    student.GeneralLook4          = GeneralLook;
                    student.TrainingStaffOpinion4 = TrainingStaffOpinion;
                    db.SaveChanges();
                    return(Json("تم الحفظ"));
                }
                if (user == "user5OpinionSec")
                {
                    student.CulturalLevel5        = CulturalLevel;
                    student.GeneralLook5          = GeneralLook;
                    student.TrainingStaffOpinion5 = TrainingStaffOpinion;
                    db.SaveChanges();
                    return(Json("تم الحفظ"));
                }
                if (user == "user6OpinionSec")
                {
                    student.CulturalLevel6        = CulturalLevel;
                    student.GeneralLook6          = GeneralLook;
                    student.TrainingStaffOpinion6 = TrainingStaffOpinion;
                    db.SaveChanges();
                    return(Json("تم الحفظ"));
                }
            }
            return(Json("لم يتم الحفظ"));
        }