Esempio n. 1
0
 public void Edit(int idComment, int idAdmin, string newTextComment)
 {
     if (_userCredentialsRepository.GetById(idAdmin).Role != "Admin")
     {
         throw new IncorrectDataException("has no access to edit");
     }
     try
     {
         Comment comment = GetById(idComment);
         comment.Text             = newTextComment;
         comment.AdminId          = idAdmin;
         comment.LastModifiedDate = DateTime.Now;
         _commentRepository.Edit(comment);
     }
     catch (DbEntityValidationException ex)
     {
         throw new IncorrectDataException(DbEntityValidationExceptioErrorMessages.ErrorMessages(ex));
     }
 }
 public UserCredentials GetById(int id)
 {
     return(_userCredentialsRepository.GetById(id));
 }