Example #1
0
 public bool isUserLiked(User user)
 {
     if (Marks != null)
         return Marks.Any(x => x.UserId == user.Id);
     else
         return true;
 }
 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;
 }
 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;
 }
        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();
        }
 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";
 }
Example #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;
 }
 public void UpdateEntity(User original, User new_value)
 {
     throw new NotImplementedException();
 }