Пример #1
0
        public virtual void SetUser(IIdentity identity, User user)
        {
            var userInformation = new UserInformation
                                      {
                                          Id = user.Id,
                                          Name = (user.Vardas + " " + user.Pavarde).Trim(),
                                          Role = user.Role
                                      };

            var principal = new OsfiPrincipal(identity, userInformation);
            HttpContext.Current.User = principal;
        }
        public ActionResult Kurimas(UserCreateModel gediminas)
        {
            if (!ModelState.IsValid) return View(gediminas);

            using (var session = _sessionFactory.OpenSession())
            using (var transaction = session.BeginTransaction())
            {
                var user = new User
                               {
                                   Username = gediminas.Username,
                                   Password = _hashAlgorithm.GetHashedString(gediminas.Password),
                                   Role = gediminas.Role.ToString(),
                                   Vardas = gediminas.Vardas,
                                   Pavarde = gediminas.Pavarde
                               };

                session.Persist(user);
                transaction.Commit();

                return RedirectToAction("Index");
            }
        }
Пример #3
0
 public virtual void AtmestiUploada(User user, int uploadId, DateTime data)
 {
     var upload = Uploads.First(x => x.Id == uploadId);
     upload.Atmesti(user, data);
 }
Пример #4
0
        public virtual void PatvirtintiUploada(User user, int uploadId, DateTime data)
        {
            var upload = Uploads.First(x => x.Id == uploadId);

            AtmestiUploaudus(Uploads.Where(x => x.Id != uploadId), upload.Metai, data);
            upload.Patvirtinti(user, data);
        }
Пример #5
0
        protected virtual bool ValidateUser(User user, string password)
        {
            if (user == null) return false;
            if (password == null) return true;

            var hash = _hashAlgorithm.GetHashedString(password);
            return user.Password == hash;
        }
Пример #6
0
        protected virtual void CreateStatus(User user, string bukle, DateTime dataNuo)
        {
            foreach (var oldStatus in Bukles.Where(x => x.DataIki == null))
            {
                oldStatus.DataIki = dataNuo;
            }

            var status = new UploadStatus
                             {
                                 Upload = this,
                                 User = user,
                                 Bukle = bukle,
                                 DataNuo = dataNuo
                             };

            Bukles.Add(status);
            Bukle = bukle;
        }
Пример #7
0
 public virtual void Patvirtinti(User user, DateTime data)
 {
     CreateStatus(user, "Patvirtintas", data);
 }
Пример #8
0
 public virtual void Atmesti(User user, DateTime data)
 {
     CreateStatus(user, "Atmestas", data);
 }