Exemplo n.º 1
0
        public void ShouldSolveRequest()
        {
            var usersBL = new UsersBL();
            usersBL.InsertUser("busaco", "busaco", "*****@*****.**", UserTypes.Teacher);
            usersBL.InsertUser("info.uaic", "info.uaic", "info.uaic", UserTypes.Faculty);

            var teacherRequestsBL = new TeacherRequestsBL();
            var teacherRequest = new TeacherRequest
                                     {
                                         DateSent = DateTime.Now,
                                         FacultyUsername = "******",
                                         TeacherUsername = "******"
                                     };
            var list = teacherRequestsBL.GetRequestsByFaculty("info.uaic");
            int length = -1;
            if (list != null) length = list.Count;
            teacherRequestsBL.InsertPendingTeacherRequest(teacherRequest);
            list = teacherRequestsBL.GetRequestsByFaculty("info.uaic");

            if (list != null) Assert.AreEqual(length + 1, list.Count);
            else Assert.Fail();

            teacherRequestsBL.SolveRequest(teacherRequest);

            list = teacherRequestsBL.GetRequestsByFaculty("info.uaic");

            // usersBL.DeleteUser("busaco", "busaco");
            // usersBL.DeleteUser("info.uaic", "info.uaic");

            if (list != null) Assert.AreEqual(length, list.Count);
            else Assert.Fail();
        }
Exemplo n.º 2
0
        public ActionResult Index(UserModel data)
        {
            if (ModelState.IsValid)
            {
                UsersBL ubl = new UsersBL();
                if ((ubl.DoesUserNameExist(data.Username)) == true)
                {
                    ViewBag.Message += "\n Username already exists";
                    return(View());
                }
                if ((ubl.DoesEmailExist(data.Email)) == true)
                {
                    ViewBag.Message += "\n E-mail address already exists";
                    return(View());
                }
                else
                {
                    ViewBag.Message = "";
                    ubl.AddUser(data.Role, data.Username, data.Password, data.Name, data.Surname, data.Email, data.Residence,
                                data.Street, data.Town, data.Country);

                    return(RedirectToAction("Index", "Users"));
                }
            }
            return(View());
        }
Exemplo n.º 3
0
        public MainForm()
        {
            listOfUsers  = new UsersBL();
            listOfAwards = new AwardsBL();

            InitializeComponent();
        }
Exemplo n.º 4
0
        public Collection <SPAProjectManager.Entities.Users> GetUsers()
        {
            var userBL = new UsersBL(mockContext);
            Collection <SPAProjectManager.Entities.Users> users = userBL.GetUsers();

            return(users);
        }
Exemplo n.º 5
0
        public static dynamic SelectByNameAndPassword(string LoginName, string Password, string CompanyId, string BranchNo)
        {
            int           result = 0;
            List <string> roles  = new List <string>();

            roles.Add("Admin");
            CustomUserAuthorizeController auth = new CustomUserAuthorizeController();
            int value = auth.validate(roles);

            if (value == (int)UserStatusEnum.UserStatus.Authorized)
            {
                Hr_Users obj = UsersBL.GetObject().SelectByNameAndPassword(LoginName, Password, CompanyId, BranchNo);
                if (obj != null && obj.UserId != null)
                {
                    result = 1;
                    HttpContext.Current.Session["Hr_UserDL"] = obj;
                }
                else
                {
                    result = 0;
                }
            }

            return(result);
            // return Ok(result);
        }
Exemplo n.º 6
0
 public async Task <User> FindAsync(string username)
 {
     using (var userBl = new UsersBL(App.ConnectionString))
     {
         return(await Task.Run(() => userBl.GetUserByUsername(username)));
     }
 }
Exemplo n.º 7
0
 public async Task <User> FindAsync(int id)
 {
     using (var userBl = new UsersBL(App.ConnectionString))
     {
         return(await userBl.GetUserById(id));
     }
 }
Exemplo n.º 8
0
        public async Task <IActionResult> Post([FromBody] Verification verification)
        {
            if (verification == null)
            {
                return(this.ApiErrorResponse(Constants.VerifiactionIsNull));
            }

            using (var usersBl = new UsersBL(App.ConnectionString))
            {
                var response = new Response();
                var user     = await usersBl.GetUserById(verification.UserId);

                if (user == null)
                {
                    return(this.ApiErrorResponse(HttpStatusCode.BadRequest, ResponseCode.UserNotExist));
                }

                verification.Code = App.CodeGenerator.GenerateKey(24);
                var v = await usersBl.CreateVerificationForUser(verification);

                if (v == null)
                {
                    return(this.ApiErrorResponse(Messages.DbError));
                }

                if (!await App.Mailer.Send(user.Email, v.Code))
                {
                    return(this.ApiErrorResponse(HttpStatusCode.Conflict, ResponseCode.UnableToSendMail));
                }

                return(this.ApiSuccessResponse());
            }
        }
        public ActionResult Download(int id)
        {
            try
            {
                //check if user has permission to download the file (Not yet done)


                //Add admin role task5
                Track track       = new TracksBL().GetTrack(id);
                User  currentUser = new UsersBL().GetUser(User.Identity.Name);

                if (track.TrackUrl != null)
                {
                    string absolutePath = Server.MapPath(track.TrackUrl);

                    if (System.IO.File.Exists(absolutePath))
                    {
                        byte[] data = System.IO.File.ReadAllBytes(absolutePath); //track as an array of bytes

                        //Decryption of (hybrid encryption)
                        MemoryStream msIn = new MemoryStream(data); //track as a memoryStream
                        msIn.Position = 0;



                        //Digital signing verifying

                        Encryption e          = new Encryption();
                        User       trackOwner = new UsersBL().GetUserById(track.userId);

                        //true if not altered, false otherwise.
                        //params : the file, public key of who uploaded the track, the track ds
                        bool secureTrack = e.VerifyData(msIn.ToArray(), trackOwner.PublicKey, track.digitalSignature);

                        if (secureTrack)
                        {
                            MemoryStream msDecrypted = Encryption.HybridDecrypt(msIn, currentUser.PrivateKey);

                            Logger.Log(User.Identity.Name, Request.Path, "Downloaded " + track.Title);

                            return(File(msDecrypted.ToArray(), System.Net.Mime.MediaTypeNames.Application.Octet,
                                        Path.GetFileName(track.TrackUrl)));
                        }
                        else
                        {
                            throw new CustomException("Download failed: File compromised");
                        }
                    }

                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                Logger.Log(User.Identity.Name, Request.Path, "Error: " + ex.Message);
                TempData["errormessage"] = ex.Message;
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
        public IActionResult ChangeProfile()
        {
            int           userId = int.Parse(_userManager.GetUserId(User));
            UserViewModel model  = UsersBL.GetUser(_context, userId);

            return(PartialView("ChangeProfile", model));
        }
        private void FormLogin_Load(object sender, EventArgs e)
        {
            if (IsNewUser == false)
            {
                LoginBL.SetCurrentUser(UserId);
                Text = "Edit usrers info";

                tbLogin.Text     = LoginBL.CurrentUser.Mail;
                tbFirstName.Text = LoginBL.CurrentUser.FirstName;
                tbLastName.Text  = LoginBL.CurrentUser.LastName;
                // LoginBL.CurrentUser.RoleId = 4;
                string gen = LoginBL.CurrentUser.Gender.Replace(" ", "");
                if (gen == "Male")
                {
                    rbMale.Checked   = true;
                    rbFemale.Checked = false;
                }
                else
                {
                    rbMale.Checked   = false;
                    rbFemale.Checked = true;
                }
                tbAdress.Text   = LoginBL.CurrentUser.Address;
                tbTel.Text      = LoginBL.CurrentUser.Tel;
                tbBankCard.Text = LoginBL.CurrentUser.BankCard;

                SecurityDTO sd = UsersBL.GetSecurityForUser(LoginBL.CurrentUser);

                tbPassword.Text        = sd.Password;
                tbKeyWord.Text         = sd.KeyWord;
                tbReenterPassword.Text = sd.Password;

                pbImage.Image = LoginBL.GetImageBinaryFromDb(LoginBL.CurrentUser.Id.ToString());
            }
        }
Exemplo n.º 12
0
 public void ShouldDeleteUser()
 {
     var bl = new UsersBL();
     bl.InsertUser("ohgoahrgorei", "ohgoahrgorei", "*****@*****.**", UserTypes.Student);
     bl.DeleteUser("ohgoahrgorei", "ohgoahrgorei");
     User user = bl.GetUser("ohgoahrgorei", "ohgoahrgorei");
     Assert.IsNull(user);
 }
Exemplo n.º 13
0
 public MainForm(ServiseOptions options)
 {
     Rewards = new RewardsBL(options);
     Users   = new UsersBL(options);
     InitializeComponent();
     DisplayUsers();
     DisplayRewards();
 }
        public IActionResult ReloadContent(bool ShowAllProject)
        {
            int  userId  = int.Parse(_userManager.GetUserId(User));
            bool isAdmin = UsersBL.UserIsAdmin(_context, userId);
            ProjectListViewModel model = ProjectsBL.ProjectListModel(_context, isAdmin, ShowAllProject, userId);

            return(PartialView("Content", model.ProjectList));
        }
Exemplo n.º 15
0
 static void Main()
 {
     usersBL   = new UsersBL();
     rewardsBL = new RewardsBL();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new MainForm());
 }
Exemplo n.º 16
0
 public MainForm()
 {
     userService     = new UsersBL(new UserModel());
     awardService    = new AwardsBL();
     awardingService = new AwardingUsersBL();
     InitializeComponent();
     ctlUsers.AutoGenerateColumns = false;
 }
Exemplo n.º 17
0
        public ActionResult Details(int?id)
        {
            if (id == null || !UsersBL.Exists(id.Value))
            {
                return(RedirectToAction("Index"));
            }

            return(View(UsersBL.Details(id.Value)));
        }
Exemplo n.º 18
0
        public void TestLogin()
        {
            string username = "******";
            string password = "******";

            bool check = new UsersBL().Login(username, password);

            Assert.AreEqual(check, true);
        }
Exemplo n.º 19
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && _usersBL != null)
            {
                _usersBL.Dispose();
                _usersBL = null;
            }

            base.Dispose(disposing);
        }
Exemplo n.º 20
0
        public FormMain()
        {
            InitializeComponent();

            _usersBL   = new UsersBL(ConfigurationManager.ConnectionStrings["ConnectionStringToTaskADONet"].ConnectionString);
            _rewardsBL = new RewardsBL(ConfigurationManager.ConnectionStrings["ConnectionStringToTaskADONet"].ConnectionString);

            DisplayUsers();
            DisplayRewards();
        }
Exemplo n.º 21
0
        public IActionResult Index()
        {
            int userId = 0;

            if (!int.TryParse(_userManager.GetUserId(HttpContext.User), out userId))
            {
                return(RedirectToAction("Login", "Account"));
            }
            return(View(UsersBL.GetUser(_context, userId)));
        }
Exemplo n.º 22
0
        private bool HasPassword()
        {
            var user = UsersBL.FindById(User.Identity.GetUserId());

            if (user != null)
            {
                return(user.PasswordHash != null);
            }
            return(false);
        }
Exemplo n.º 23
0
        private bool HasPhoneNumber()
        {
            var user = UsersBL.FindById(User.Identity.GetUserId());

            if (user != null)
            {
                return(user.PhoneNumber != null);
            }
            return(false);
        }
Exemplo n.º 24
0
        protected void Btn_Click(object sender, EventArgs e)
        {
            bool isOK = UsersBL.Login(tbxUserName.Text, tbxPassword.Text);

            if (!isOK)
            {
                this.lblStatus.Text    = "Wrong username and/or password !!";
                this.lblStatus.Visible = true;
            }
        }
Exemplo n.º 25
0
        public FormMain()
        {
            InitializeComponent();

            _usersBL   = new UsersBL(new UsersSql());
            _rewardsBL = new RewardsBL(new RewardsSql());

            DisplayUsers();
            DisplayRewards();
        }
Exemplo n.º 26
0
        public ActionResult Edit(int?id)
        {
            if (id == null || !UsersBL.Exists(id.Value))
            {
                return(RedirectToAction("Index"));
            }

            User editUser = UsersBL.Details(id.Value);

            return(View(editUser));
        }
Exemplo n.º 27
0
 public void ShouldInsertGroups()
 {
     var usersBL = new UsersBL();
     var student = usersBL.GetStudent("Adrian2");
     student.SubscribedGroups = new List<string>
                                    {
                                        "cc0df0c3-6fac-4f65-98ac-fee10dcf38b7",
                                        "21c8d489-e9be-4127-864f-80e387ab3592"
                                    };
     usersBL.SaveStudent(student);
 }
 public IHttpActionResult GeByUserName(string userName)
 {
     try
     {
         return(Ok(UsersBL.GeByUserName(userName)));
     }
     catch
     {
         return(NotFound());
     }
 }
 public IHttpActionResult GetById(int userId)
 {
     try
     {
         return(Ok(UsersBL.GetUserById(userId)));
     }
     catch
     {
         return(NotFound());
     }
 }
 public IHttpActionResult Post([FromBody] Users1 user)
 {
     try
     {
         UsersBL.AddUser(user);
         return(Ok());
     }
     catch
     {
         return(Conflict());
     }
 }
 // DELETE: api/Users/5
 public IHttpActionResult Delete(int id, [FromBody] Users1 user)
 {
     try
     {
         UsersBL.DeleteUser(user);
         return(Ok());
     }
     catch
     {
         return(Conflict());
     }
 }
 public JsonResult RemoveUser(int userId)
 {
     try
     {
         UsersBL.RemoveUser(_context, userId);
         return(Json("SUCCESS"));
     }
     catch (Exception ex)
     {
         return(Json(ex.Message));
     }
 }
 public IHttpActionResult Put([FromBody] Users1 user)
 {
     try
     {
         UsersBL.UpdateUser(user);
         return(Ok());
     }
     catch
     {
         return(NotFound());
     }
 }
Exemplo n.º 34
0
 public void ShouldInsertComplexStudent()
 {
     var student = new Student
                       {
                           Email = "*****@*****.**",
                           Name = "Adrian Marinica",
                           Id = "Adrian3",
                           IsApproved = true,
                           IsLockedOut = false,
                           Notifications = new List<UserNotification>
                                               {
                                                   new UserNotification
                                                       {NotificationId = "1", UserSolved = false},
                                                   new UserNotification
                                                       {NotificationId = "2", UserSolved = false}
                                               },
                           SubscribedWebsites = new List<string>
                                                    {
                                                        "http://info.uaic.ro/~busaco/",
                                                        "http://info.uaic.ro/~rvlad/"
                                                    },
                           SubscribedGroups = new List<string>
                                                  {
                                                      "asfsagasgagas",
                                                      "asdbsdvsdvwe"
                                                  },
                           SubscribedFaculties = new List<string>
                                                     {
                                                         "info.uaic.ro"
                                                     },
                           FailedSubjects = new List<string>
                                                {
                                                     "4fcd249affd8e810ecc3c15f"
                                                },
                           OptionalSubjects = new List<string>
                                                  {
                                                      "4fcd249affd8e810ecc3c15e"
                                                  }
                       };
     var usersBL = new UsersBL();
     usersBL.InsertUser(student);
 }
Exemplo n.º 35
0
 private string GetGroupIdByName(string s)
 {
     var usersBL = new UsersBL();
     return usersBL.GetGroupIdByName("info.uaic.ro", s);
 }
Exemplo n.º 36
0
        public void ShouldSetFIIFacultyGroups()
        {
            var bl = new UsersBL();
            var fullFaculty = new GenericGroup("FII");
            fullFaculty.Groups = new List<GenericGroup>();

            #region Bachelor
            var bachelor1 = new GenericGroup("I1");
            var bachelor1A = new GenericGroup("I1A");
            var bachelor1B = new GenericGroup("I1B");
            bachelor1A.Groups = new List<GenericGroup>();
            bachelor1B.Groups = new List<GenericGroup>();
            for (int i = 1; i < 8; i++)
            {
                bachelor1A.Groups.Add(new GenericGroup("I1A" + i));
                bachelor1B.Groups.Add(new GenericGroup("I1B" + i));
            }
            bachelor1.Groups.Add(bachelor1A);
            bachelor1.Groups.Add(bachelor1B);

            var bachelor2 = new GenericGroup("I2");
            var bachelor2A = new GenericGroup("I2A");
            var bachelor2B = new GenericGroup("I2B");
            bachelor2A.Groups = new List<GenericGroup>();
            bachelor2B.Groups = new List<GenericGroup>();
            for (int i = 1; i < 8; i++)
            {
                bachelor2A.Groups.Add(new GenericGroup("I2A" + i));
                bachelor2B.Groups.Add(new GenericGroup("I2B" + i));
            }
            bachelor2.Groups.Add(bachelor2A);
            bachelor2.Groups.Add(bachelor2B);

            var bachelor3 = new GenericGroup("I3");
            var bachelor3A = new GenericGroup("I3A");
            var bachelor3B = new GenericGroup("I3B");
            bachelor3A.Groups = new List<GenericGroup>();
            bachelor3B.Groups = new List<GenericGroup>();
            for (int i = 1; i < 6; i++)
            {
                bachelor3A.Groups.Add(new GenericGroup("I3A" + i));
                bachelor3B.Groups.Add(new GenericGroup("I3B" + i));
            }
            bachelor3.Groups.Add(bachelor3B);
            bachelor3.Groups.Add(bachelor3B);

            fullFaculty.Groups.Add(bachelor1);
            fullFaculty.Groups.Add(bachelor2);
            fullFaculty.Groups.Add(bachelor3);
            #endregion

            #region Masters
            var mis1 = new GenericGroup("MIS1");
            mis1.Groups.Add(new GenericGroup("MIS11"));
            mis1.Groups.Add(new GenericGroup("MIS12"));
            var mis2 = new GenericGroup("MIS2");
            mis2.Groups.Add(new GenericGroup("MIS21"));
            mis2.Groups.Add(new GenericGroup("MIS22"));

            var mlc1 = new GenericGroup("MLC1");
            var mlc2 = new GenericGroup("MLC2");

            var moc1 = new GenericGroup("MOC1");
            var moc2 = new GenericGroup("MOC2");

            var msd1 = new GenericGroup("MSD1");
            var msd2 = new GenericGroup("MSD2");

            var msi1 = new GenericGroup("MSI1");
            var msi2 = new GenericGroup("MSI2");

            fullFaculty.Groups.Add(mis1);
            fullFaculty.Groups.Add(mis2);
            fullFaculty.Groups.Add(mlc1);
            fullFaculty.Groups.Add(mlc2);
            fullFaculty.Groups.Add(moc1);
            fullFaculty.Groups.Add(moc2);
            fullFaculty.Groups.Add(msd1);
            fullFaculty.Groups.Add(msd2);
            fullFaculty.Groups.Add(msi1);
            fullFaculty.Groups.Add(msi2);
            #endregion

            bl.SetFacultyGroups("info.uaic.ro", fullFaculty);
        }
Exemplo n.º 37
0
        public void ShouldSetTimetableForFii()
        {
            var timetablesBL = new TimetablesBL();
            var usersBL = new UsersBL();
            List<string> list = usersBL.GetGroupsByFaculty("info.uaic.ro");

            foreach (var group in list)
            {
                Timetable timetable = new Timetable();
                timetable.Faculty = "info.uaic.ro";
                timetable.GroupId = group;
                string name = usersBL.GetGroupName(group, "info.uaic.ro");

                    StudyYear year = StudyYear.None;
                    HalfYear halfYear = HalfYear.None;
                    string number = null;

                    if(name.StartsWith("I")) // licenta
                    {
                        if(name.StartsWith("I1")) // lic 1
                        {
                            year = StudyYear.I1;
                        }
                        else if(name.StartsWith("I2")) // lic 2
                        {
                            year = StudyYear.I2;
                        }
                        else if(name.StartsWith("I3")) // lic 3
                        {
                            year = StudyYear.I3;
                        }

                        if (name.Length > 2)
                        {
                            switch (name[2])
                            {
                                case 'A':
                                    halfYear = HalfYear.A;
                                    break;
                                case 'B':
                                    halfYear = HalfYear.B;
                                    break;
                            }
                        }
                        number = name.Substring(3);
                    }
                    else if(name.StartsWith("M")) // master
                    {
                        halfYear = HalfYear.None;
                        if(name.StartsWith("MIS"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MIS1;
                                    break;
                                case '2':
                                    year = StudyYear.MIS2;
                                    break;
                            }
                            number = name[4].ToString();
                        }
                        else if(name.StartsWith("MLC"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MLC1;
                                    break;
                                case '2':
                                    year = StudyYear.MLC2;
                                    break;
                            }
                        }
                        else if (name.StartsWith("MOC"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MOC1;
                                    break;
                                case '2':
                                    year = StudyYear.MOC2;
                                    break;
                            }
                        }
                        else if (name.StartsWith("MSD"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MSD1;
                                    break;
                                case '2':
                                    year = StudyYear.MSD2;
                                    break;
                            }
                        }
                        else if (name.StartsWith("MSI"))
                        {
                            switch (name[3])
                            {
                                case '1':
                                    year = StudyYear.MSI1;
                                    break;
                                case '2':
                                    year = StudyYear.MSI2;
                                    break;
                            }
                        }
                    }
                    var parser = new Parser();
                    var timetableForGroup = parser.GetTimetableForGroup(year, halfYear, number);

                timetable.TimetableItems = ConvertToRegularTimetable(timetableForGroup);
                timetablesBL.SaveTimetable(timetable);
            }
        }
Exemplo n.º 38
0
 public void ShouldGetAllStudents()
 {
     UsersBL bl = new UsersBL();
     var list = bl.GetAllStudents();
 }
Exemplo n.º 39
0
 public void ShouldValidateUser()
 {
     var bl = new UsersBL();
     bl.InsertUser("ohgoahrgorei", "ohgoahrgorei", "*****@*****.**", UserTypes.Student);
     Assert.IsTrue(bl.ValidateUser("ohgoahrgorei", "ohgoahrgorei", UserTypes.Student));
     Assert.IsFalse(bl.ValidateUser("ohgoahrgorei", "ohgoahrgorei111", UserTypes.Student));
     bl.DeleteUser("ohgoahrgorei", "ohgoahrgorei");
     Assert.IsFalse(bl.ValidateUser("ohgoahrgorei", "ohgoahrgorei", UserTypes.Student));
 }
Exemplo n.º 40
0
 public void ShouldInsertUserOnlyOnceAndThenDeleteIt()
 {
     var bl = new UsersBL();
     bl.InsertUser("ohgoahrgorei", "ohgoahrgorei", "*****@*****.**", UserTypes.Student);
     bool actual = bl.InsertUser("ohgoahrgorei", "ohgoahrgorei", "*****@*****.**", UserTypes.Student);
     bl.DeleteUser("ohgoahrgorei", "ohgoahrgorei");
     Assert.IsFalse(actual);
     Assert.IsFalse(bl.ValidateUser("ohgoahrgorei", "ohgoahrgorei", UserTypes.Student));
 }