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"); } }
public virtual void AtmestiUploada(User user, int uploadId, DateTime data) { var upload = Uploads.First(x => x.Id == uploadId); upload.Atmesti(user, data); }
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); }
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; }
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; }
public virtual void Patvirtinti(User user, DateTime data) { CreateStatus(user, "Patvirtintas", data); }
public virtual void Atmesti(User user, DateTime data) { CreateStatus(user, "Atmestas", data); }