public void Delete(DalMovie entity) { var movie = context.Set <Movies>().Single(mov => mov.Id == entity.Id); context.Set <Movies>().Remove(movie); context.SaveChanges(); }
public void Update(DalMovie entity) { var result = context.Set <Movies>().First(x => x.Id == entity.Id); result.Title = entity.Title; result.Description = entity.Description; result.Year = entity.Year; result.Length = entity.Length; result.Mark = entity.Mark; result.Producer = entity.Producer; result.Budget = entity.Budget; result.Picture = entity.Picture; result.Data = entity.Data; context.Set <Movies>().Attach(result); var entry = context.Entry(result); entry.Property(x => x.Title).IsModified = true; entry.Property(x => x.Description).IsModified = true; entry.Property(x => x.Year).IsModified = true; entry.Property(x => x.Length).IsModified = true; entry.Property(x => x.Mark).IsModified = true; entry.Property(x => x.Producer).IsModified = true; entry.Property(x => x.Budget).IsModified = true; //entry.Property(x => x.Data).IsModified = true; entry.Property(x => x.Picture).IsModified = true; context.SaveChanges(); }
//Movie public static MovieEntity ToBllMovie(this DalMovie dalMovie) { return(new MovieEntity() { Id = dalMovie.Id, Title = dalMovie.Title, Description = dalMovie.Description, Year = dalMovie.Year, Length = dalMovie.Length, Mark = dalMovie.Mark, Producer = dalMovie.Producer, Budget = dalMovie.Budget, Picture = dalMovie.Picture, Data = dalMovie.Data }); }
public void Create(DalMovie entity) { var movie = new Movies() { Title = entity.Title, Description = entity.Description, Year = entity.Year, Length = entity.Length, Mark = entity.Mark, Producer = entity.Producer, Budget = entity.Budget, Picture = entity.Picture, Data = entity.Data }; context.Set <Movies>().Add(movie); context.SaveChanges(); }