예제 #1
0
 public bool isUserLiked(User user)
 {
     if (Marks != null)
         return Marks.Any(x => x.UserId == user.Id);
     else
         return true;
 }
예제 #2
0
 public Publication Delete(int id, User user)
 {
     var pub = Get(id);
     if (pub.UserId == user.Id || user.Role == UserRole.Admin)
         pub.Status = PublicationStatus.Deleted;
     db.SaveChanges();
     return pub;
 }
예제 #3
0
 public Publication Approve(PublicationStatus status, int id, User user)
 {
     var pub = Get(id);
     if (user.Role == UserRole.Admin)
     {
         pub.Status = status;
         db.SaveChanges();
     }
     return pub;
 }
예제 #4
0
        public void Create(string text, User creator, TextLanguageType lang_type)
        {
            Publication p = new Publication();
            p.Text = HttpUtility.HtmlEncode(text);

            if (!db.Users.Any(x => x.Id == creator.Id))
                throw new Exception("Unknown creator");

            p.UserId = creator.Id;
            p.LangType = lang_type;
            p.CreationDate = DateTime.Now;
            p.Status = PublicationStatus.OnCheck;
            db.Publications.Add(p);
            db.SaveChanges();
        }
예제 #5
0
 public string AddMark(int id, User creator, int value)
 {
     var publication = Get(id);
     if (publication != null)
     {
         PublicationMark mark = new PublicationMark();
         mark.UserId = creator.Id;
         mark.PublicationId = publication.Id;
         mark.Value = value;
         db.PublicationMarks.Add(mark);
         db.SaveChanges();
         return publication.overallMarkAsString();
     }
     else
         return "0";
 }
예제 #6
0
 public bool isUserCreator(User user)
 {
     return Creator.Id == user.Id;
 }
 public User CreateUser(string email, string password)
 {
     var user = new User(email, password);
     viewModel.Create(user);
     return user;
 }
예제 #8
0
 public void UpdateEntity(User original, User new_value)
 {
     throw new NotImplementedException();
 }