public override int Create(Server item) { using (var db = DbContextService.GetDbContext()) { var dbItem = db.Servers.Add(item); db.SaveChanges(); return(dbItem.Id); } }
public override IEnumerable <Recipient> GetItems() { //return DbContextService.Do(db => //{ // var recipients = db.Recipients.ToArray(); // return recipients; //}) as IEnumerable<Recipient>; using (var db = DbContextService.GetDbContext()) return(db.Recipients.ToArray()); }
public override void Update(int id, Recipient item) { using (var db = DbContextService.GetDbContext()) { var dbRecipient = db.Recipients.FirstOrDefault(r => r.Id == item.Id); if (dbRecipient == null) { return; } dbRecipient.Name = item.Name; dbRecipient.Address = item.Address; db.SaveChanges(); } }
public override void Update(int id, Server item) { using (var db = DbContextService.GetDbContext()) { var dbServer = db.Servers.FirstOrDefault(r => r.Id == item.Id); if (dbServer == null) { return; } dbServer.Name = item.Name; dbServer.Address = item.Address; dbServer.Port = item.Port; dbServer.UseSSL = item.UseSSL; dbServer.Login = item.Login; dbServer.Password = item.Password; db.SaveChanges(); } }
public override Server GetById(int id) { using (var db = DbContextService.GetDbContext()) return(db.Servers.FirstOrDefault(r => r.Id == id)); }
public override IEnumerable <Server> GetItems() { using (var db = DbContextService.GetDbContext()) return(db.Servers.ToArray()); }