Example #1
0
        public void Add(BondeModel model)
        {
            if (IsTaken(model.Brukernavn))
            {
                throw new UserException(ExceptionType.BrukernavnIsTaken);
            }

            using (var work = _unitOfWork.Begin())
            {
                var bonde = _repo.Save(model.ToEntity());
                var bruker = _repo.GetAll<Rolle>().Single(r => r.Kode.Equals(UserRole.Bruker));
                bonde.AddRolle(bruker);
                work.Complete();
            }
        }
Example #2
0
        public void Add(BondeModel model)
        {
            if (IsTaken(model.Brukernavn))
            {
                throw new UserException(ExceptionType.BrukernavnIsTaken);
            }

            using (var work = _unitOfWork.Begin())
            {
                var bonde  = _repo.Save(model.ToEntity());
                var bruker = _repo.GetAll <Rolle>().Single(r => r.Kode.Equals(UserRole.Bruker));
                bonde.AddRolle(bruker);
                work.Complete();
            }
        }
 public void GenerateBondegards(BondeModel bondeModel, int number)
 {
     using (var work = _unitOfWork.Begin())
     {
         var bonde = _repo.Get <Bonde>(bondeModel.Id);
         for (var ii = 1; ii < number + 1; ii++)
         {
             var bondegard = new Bondegard {
                 Navn = string.Format("BondegÄrd {0}", ii), Bonde = bonde
             };
             _repo.Save(bondegard);
             CreateTraktorer(3).Each(bondegard.AddTraktor);
             CreateFjoser(3).Each(bondegard.AddFjos);
             CreateStaller(2).Each(bondegard.AddStall);
         }
         work.Complete();
     }
 }
Example #4
0
 public UserContext(BondeModel bonde)
 {
     Bonde = bonde;
 }
 public RegisterBondeViewModel(BondeModel bonde)
 {
     Bonde = bonde;
 }
Example #6
0
 public void LogIn(BondeModel bonde)
 {
     _sessionManager.UserContext = new UserContext(bonde);
     FormsAuthentication.SetAuthCookie(bonde.Brukernavn, true);
 }
Example #7
0
 public void LogIn(BondeModel bonde)
 {
     _sessionManager.UserContext = new UserContext(bonde);
     FormsAuthentication.SetAuthCookie(bonde.Brukernavn, true);
 }
 public RegisterBondeViewModel(BondeModel bonde)
 {
     Bonde = bonde;
 }
Example #9
0
 public UserContext(BondeModel bonde)
 {
     Bonde = bonde;
 }