/// <summary> /// If the ‘username’ exists, assigns the reviewer’s username to the session in the system. If not, triggers an event /// which will send out an email to invite a new reviewer to register an account with the system. /// </summary> /// <remarks> /// The event persist the session id for which the new user will be assign as a reviewer. /// This will be used by the Account Monitor to assign the new reviewer’s username to the session in the system. /// </remarks> /// <param name="reviewer">The username of the reviewer</param> /// <param name="sessionId">The id of the review session</param> /// <param name="current">The API user's username</param> /// <exception cref="SessionNotFoundException"></exception> /// <exception cref="AuthorizationException"></exception> /// <exception cref="InvalidOperationException"></exception> public void AssignReviewer(int sessionId, string reviewer, string current) { var session = _sessionRepository.Get(sessionId); if (session == null) { throw new SessionNotFoundException(); } if (session.PendingReviewer) { throw new InvalidOperationException(); } if (session.Creator.ToLower() != current.ToLower()) { throw new AuthorizationException(); } session.Reviewer = reviewer; _sessionRepository.Save(session); var assignEvent = new Event { Created = DateTime.UtcNow, EntityId = session.Id, EventType = EventType.ReviewerAssigned, Info = new Dictionary <string, string> { { "username", reviewer } } }; _eventRepository.Save(assignEvent); }
public void CreateNew(Account account) { if (UserExists(account.Username)) { throw new UserAlreadyExistsException(); } if (InvalidUserName(account.Username)) { throw new InvalidUsernameException(); } if (InvalidEmailAddres(account.EmailAddress)) { throw new InvalidEmailAddressException(); } var user = new WebSecurityUser(); user.SetDefaultStatistics("system"); // Copy over default stats account.LastModified = user.Statistics.LastModified.Value; account.LastLogin = user.Statistics.LastLogin.Value; account.LastLoginAttempted = user.Statistics.LastLoginAttempted.Value; account.LastPasswordChanged = user.Statistics.LastPasswordChanged.Value; account.Password = _passwordManager.EncryptPassword(account.Password, BCryptEncoder.GenerateSalt(), BCryptEncoder.HashPassword); _repository.Save(account); }
public void AddProposal(string paper_name, string co_authors, string[] keywords, string[] topics, string abstractFileName, string paperFileName, User author, Edition ed) { PaperMetaInformation metaInfo = new PaperMetaInformation(paper_name, string.Join(",", keywords), author, co_authors); metaInfoRepo.Save(metaInfo); foreach (string topic in topics) { Topic t = new Topic(topic); topicsRepo.Save(t); MetaInformationTopics mit = new MetaInformationTopics(t, metaInfo); metaTopicsRepo.Save(mit); } Abstract abs = (abstractFileName != "") ? new Abstract(abstractFileName) : null; Paper paper = (paperFileName != "") ? new Paper(paperFileName, abs, metaInfo, ed) : null; if (abs != null) { abstractRepo.Save(abs); } if (paper != null) { paerRepo.Save(paper); } }
/// <summary> /// Function to add a new grade to the repository /// </summary> /// <param name="stId">id of the student</param> /// <param name="hwId">id of the homework</param> /// <param name="gradeValue">grade value</param> /// <param name="professor">professor name</param> /// <param name="feedback">feedback</param> /// <exception cref="StudentOrHomeworNotFoundException">if the given homework or student does not exist</exception> /// <returns>null if the grade was added, the given grade otherwise</returns> public Grade AddGrade(int stId, string hwId, double gradeValue, string professor, string feedback) { var st = _stRepo.FindOne(stId); var hw = _hwRepo.FindOne(hwId); if (st == null || hw == null) { throw new StudentOrHomeworNotFoundException("The given student or homework does not exist!"); } var diff = hw.DeadlineWeek - Utility.GetCurrentWeek(); if (diff == -1 || diff == -2) { gradeValue += (2.5d) * diff; } else if (diff < -2) { gradeValue = 1.0d; } return(_grRepo.Save(new Grade(stId, hwId, gradeValue, professor, feedback))); }
public void Save(AbstractRepository repo) { repo.Save <Category>(this); }
public void Save(AbstractRepository repo) { repo.Save <Account>(this); }
/// <summary> /// Function to add a new homework into the repository /// </summary> /// <param name="id">id of the homework</param> /// <param name="desc">description of the homework</param> /// <param name="receivingWeek">receiving week</param> /// <param name="deadlineWeek">deadline week</param> /// <returns>null if the homework is added, the given homework otherwise</returns> public Homework AddHomework(string id, string desc, int receivingWeek, int deadlineWeek) { return(_hwRepo.Save(new Homework(id, desc, receivingWeek, deadlineWeek))); }
public void DoSomething() { // Используем _repository _repository.Save(); }
public void Save(AbstractRepository repo) { repo.Save <Format>(this); }
public void Save(AbstractRepository repo) { repo.Save <Book>(this); }
/// <summary> /// Function to add a new student to the repository /// </summary> /// <param name="id">id of the student to be added</param> /// <param name="name">name of the student</param> /// <param name="group">group of the student</param> /// <param name="email">email of the student</param> /// <returns>null if the student was added, the Student otherwise</returns> public Student AddStudent(int id, string name, int group, string email) { return(_studRepo.Save(new Student(id, name, group, email))); }