public void Delete(DalTheme entity) { var ormTheme = entity.ToOrmTheme(); var theme = context.Set <Theme>().FirstOrDefault(u => u.Id == ormTheme.Id); context.Set <Theme>().Attach(theme); context.Set <Theme>().Remove(theme); context.Entry(theme).State = System.Data.Entity.EntityState.Deleted; }
public void Delete(DalTheme entity) { var theme = context.Set <Theme>().Where(th => th.Id == entity.Id).FirstOrDefault(); if (theme != null) { context.Set <Theme>().Remove(theme); } }
public void Update(DalTheme entity) { if (entity != null) { var themeToUpdate = context.Set <Theme>().FirstOrDefault(u => u.Id == entity.Id); var ormTheme = entity.ToOrmTheme(); context.Set <Theme>().Attach(themeToUpdate); themeToUpdate.Name = ormTheme.Name; context.Entry(themeToUpdate).State = System.Data.Entity.EntityState.Modified; } }
public void Update(DalTheme entity) { var theme = context.Set <Theme>().Where(th => th.Id == entity.Id).FirstOrDefault(); if (theme != null) { theme.Name = entity.Name; theme.DatePublication = entity.DatePublication; theme.CountViews = entity.CountViews; theme.CreatorId = entity.CreatorId; theme.SectionId = entity.SectionId; theme.Content = entity.Content; } }
public static Theme ToOrmTheme(this DalTheme dalTheme) { if (dalTheme == null) { return(null); } var ormTheme = new Theme() { Id = dalTheme.Id, Name = dalTheme.Name }; return(ormTheme); }
public static DalTheme ToDalTheme(this Theme ormTheme) { if (ormTheme == null) { return(null); } var dalTheme = new DalTheme() { Id = ormTheme.Id, Name = ormTheme.Name, }; return(dalTheme); }
public static BllTheme ToBllTheme(this DalTheme dalTheme) { if (dalTheme == null) { return(null); } var bllTheme = new BllTheme() { Id = dalTheme.Id, Name = dalTheme.Name }; return(bllTheme); }
public static DalTheme ToDalTheme(this BllTheme bllTheme) { if (bllTheme == null) { return(null); } var dalTheme = new DalTheme() { Id = bllTheme.Id, Name = bllTheme.Name, }; return(dalTheme); }
public void Create(DalTheme entity) { var theme = new Theme() { Id = entity.Id, Name = entity.Name, DatePublication = entity.DatePublication, CountViews = entity.CountViews, CreatorId = entity.CreatorId, SectionId = entity.SectionId, Content = entity.Content }; context.Set <Theme>().Add(theme); }
public static ThemeEntity ToBllTheme(this DalTheme dalTheme) { if (dalTheme != null) { return(new ThemeEntity() { Id = dalTheme.Id, Name = dalTheme.Name, DatePublication = dalTheme.DatePublication, CountViews = dalTheme.CountViews, CreatorId = dalTheme.CreatorId, SectionId = dalTheme.SectionId, Content = dalTheme.Content }); } return(null); }
public void Create(DalTheme entity) { var theme = entity.ToOrmTheme(); context.Set <Theme>().Add(theme); }