예제 #1
0
 public void Create(DalMark entity)
 {
     Mark mark = new Mark()
     {
         Value = entity.Value
     };
     _context.Set<Mark>().Add(mark);
 }
예제 #2
0
 public void Update(DalMark entity)
 {
     Mark mark = new Mark()
     {
         Id = entity.Id,
         Value = entity.Value
     };
     _context.Set<Mark>().AddOrUpdate(mark);
 }
예제 #3
0
 public void Delete(DalMark entity)
 {
     Mark mark = new Mark()
     {
         Id = entity.Id,
         Value = entity.Value
     };
     mark = _context.Set<Mark>().Single(m => m.Id == mark.Id);
     _context.Set<Mark>().Remove(mark);
 }
 public DalMark GetMovieMarks(int id)
 {
     var userList = context.Set<UserMovieMarks>().Where(x => x.IdMovie == id);
     DalMark result = new DalMark()
         {
             Marks = new Dictionary<int, int>(),
             Target = id
         };
     foreach (var item in userList)
     {
         result.Marks[item.IdUser] = item.Mark;
     } 
     return result;
 }
 public void Create(DalMark entity)
 {
     var mark = new UserMovieMarks()
     {
         IdMovie = entity.MovieId,
         IdUser = entity.UserId,
         Mark = entity.Mark
     };
     context.Set<UserMovieMarks>().Add(mark);
     context.SaveChanges();
 }
 public void Update(DalMark entity)
 {
     var mark = context.Set<UserMovieMarks>().Where(x => x.Id == entity.Id).FirstOrDefault();
     mark.Mark = entity.Mark;
     mark.IdMovie = entity.MovieId;
     mark.IdUser = entity.UserId;
     context.Set<UserMovieMarks>().Attach(mark);
     var entry = context.Entry(mark);
     //entry.Property(x => x.Movies).IsModified = false;
     //entry.Property(x => x.Users).IsModified = false;
     entry.Property(x => x.Mark).IsModified = true;
     context.SaveChanges();
 }
 public void Delete(DalMark entity)
 {
     var result = context.Set<UserMovieMarks>().Where(x => x.Id == entity.Id).Single();
     context.Set<UserMovieMarks>().Remove(result);
     context.SaveChanges();
 }