public void Can_Edit_Submitted()
        {
            var service = new SessionService(null);
            var user = new User { Id = 1, IsAdministrator = true };
            var session = new Session { Id = 1 };
            var permissions = service.GetPermissionModel(session, user);

            Assert.AreEqual(permissions.CanEdit, true);
        }
        public void Can_Edit_AdminRejected()
        {
            var service = new SessionService(null);
            var user = new User { Id = 1, IsDeleted = false, IsAdministrator = true };
            var session = new Session { Id = 1, UserSubmittedAt = DateTime.Now, AdminSubmittedAt = DateTime.Now, IsAccepted = false, RejectionReason = "I want" };
            var permissions = service.GetPermissionModel(session, user);

            Assert.AreEqual(permissions.CanEdit, true);
        }
예제 #3
0
        public virtual ActionResult Register(string Username, string Password, string RepeatPassword, int Age)
        {
            try
            {
                if (Password == RepeatPassword)
                {
                    if (!this.unitOfWork.UserRepository.Get(u => u.Username == Username).Any())
                    {
                        User user = new User { Username = Username, Password = Password, Age = Age };
                        this.unitOfWork.UserRepository.Insert(user);
                        this.unitOfWork.Save();
                        return this.RedirectToAction(MVC.Home.Index());
                    }

                    ModelState.AddModelError("error", "User already registered!");
                    return this.View();
                }

                ModelState.AddModelError("error", "Passwords do not mach!");
                return this.View();
            }
            catch (Exception ex)
            {
                Log.LogError(ex);
                throw;
            }
        }