示例#1
0
 public override int Create(Server item)
 {
     using (var db = DbContextService.GetDbContext())
     {
         var dbItem = db.Servers.Add(item);
         db.SaveChanges();
         return(dbItem.Id);
     }
 }
示例#2
0
 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());
 }
示例#3
0
        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();
            }
        }
示例#4
0
        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();
            }
        }
示例#5
0
 public override Server GetById(int id)
 {
     using (var db = DbContextService.GetDbContext())
         return(db.Servers.FirstOrDefault(r => r.Id == id));
 }
示例#6
0
 public override IEnumerable <Server> GetItems()
 {
     using (var db = DbContextService.GetDbContext())
         return(db.Servers.ToArray());
 }