コード例 #1
0
 public List <Vaccine> GetList()
 {
     using (this.context = new PetControlEntities())
     {
         return(this.context.Vaccines.ToList());
     }
 }
コード例 #2
0
        public bool Update(ref Record newRecord)
        {
            try
            {
                var id = newRecord.id;
                using (this.context = new PetControlEntities())
                {
                    var oldRecord = this.context.Records.SingleOrDefault(b => b.id == id);
                    if (oldRecord != null)
                    {
                        oldRecord.isVaccine    = newRecord.isVaccine;
                        oldRecord.notes        = newRecord.notes;
                        oldRecord.recordNumber = newRecord.recordNumber;
                        oldRecord.status       = newRecord.status;
                        oldRecord.tags         = newRecord.tags;
                        oldRecord.type         = newRecord.type;
                        this.context.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
コード例 #3
0
 public List <Record> GetList()
 {
     using (this.context = new PetControlEntities())
     {
         return(this.context.Records.ToList());
     }
 }
コード例 #4
0
        public bool Update(ref Vaccine newVaccine)
        {
            try
            {
                var id = newVaccine.id;
                using (this.context = new PetControlEntities())
                {
                    var oldVaccine = this.context.Vaccines.SingleOrDefault(b => b.id == id);
                    if (oldVaccine != null)
                    {
                        oldVaccine.cost        = newVaccine.cost;
                        oldVaccine.description = newVaccine.description;
                        oldVaccine.disease     = newVaccine.disease;
                        oldVaccine.living      = newVaccine.living;
                        oldVaccine.name        = newVaccine.name;
                        oldVaccine.preparation = newVaccine.preparation;
                        oldVaccine.type        = newVaccine.type;
                        this.context.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
コード例 #5
0
ファイル: UserDAL.cs プロジェクト: dennieru/SIS3651BackEnd
        public bool Update(ref User newUser)
        {
            try
            {
                var id = newUser.id;
                using (this.context = new PetControlEntities())
                {
                    var oldUser = this.context.Users.SingleOrDefault(b => b.id == id);
                    if (oldUser != null)
                    {
                        oldUser.address     = newUser.address;
                        oldUser.description = newUser.description;
                        oldUser.email       = newUser.email;
                        oldUser.firstName   = newUser.firstName;
                        oldUser.lastName    = newUser.lastName;
                        oldUser.nickName    = newUser.nickName;
                        this.context.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
コード例 #6
0
        public bool Update(ref Pet newPet)
        {
            try
            {
                var id = newPet.id;
                using (this.context = new PetControlEntities())
                {
                    var oldPet = this.context.Pets.SingleOrDefault(b => b.id == id);
                    if (oldPet != null)
                    {
                        oldPet.name        = newPet.name;
                        oldPet.specie      = newPet.specie;
                        oldPet.birthDate   = newPet.birthDate;
                        oldPet.breed       = newPet.breed;
                        oldPet.description = newPet.description;
                        this.context.SaveChanges();
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
コード例 #7
0
 public List <Pet> GetList()
 {
     using (this.context = new PetControlEntities())
     {
         return(this.context.Pets.ToList());
     }
 }
コード例 #8
0
ファイル: UserDAL.cs プロジェクト: dennieru/SIS3651BackEnd
        public User Get(string id)
        {
            try
            {
                User user;
                using (this.context = new PetControlEntities())
                {
                    user = this.context.Users.SingleOrDefault(u => u.id == new Guid(id));
                }

                return(user);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #9
0
        public Record Get(string id)
        {
            try
            {
                Record record;
                using (this.context = new PetControlEntities())
                {
                    record = this.context.Records.SingleOrDefault(u => u.id == new Guid(id));
                }

                return(record);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #10
0
        public Vaccine Get(string id)
        {
            try
            {
                Vaccine vaccine;
                using (this.context = new PetControlEntities())
                {
                    vaccine = this.context.Vaccines.SingleOrDefault(u => u.id == new Guid(id));
                }

                return(vaccine);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #11
0
        public Pet Get(string id)
        {
            try
            {
                Pet pet;
                using (this.context = new PetControlEntities())
                {
                    pet = this.context.Pets.SingleOrDefault(u => u.id == new Guid(id));
                }

                return(pet);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
コード例 #12
0
        public bool Post(Record record)
        {
            try
            {
                record.id = Guid.NewGuid();
                using (this.context = new PetControlEntities())
                {
                    this.context.Records.Add(record);
                    this.context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
コード例 #13
0
        public bool Post(Vaccine vaccine)
        {
            try
            {
                vaccine.id = Guid.NewGuid();
                using (this.context = new PetControlEntities())
                {
                    this.context.Vaccines.Add(vaccine);
                    this.context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
コード例 #14
0
        public bool Delete(string id)
        {
            try
            {
                using (this.context = new PetControlEntities())
                {
                    Record record = new Record {
                        id = new Guid(id)
                    };
                    this.context.Records.Attach(record);
                    this.context.Records.Remove(record);
                    this.context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                return(false);
            }
        }
コード例 #15
0
        public bool Delete(string id)
        {
            try
            {
                using (this.context = new PetControlEntities())
                {
                    var vaccine = new Vaccine {
                        id = new Guid(id)
                    };
                    this.context.Vaccines.Attach(vaccine);
                    this.context.Vaccines.Remove(vaccine);
                    this.context.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                return(false);
            }
        }
コード例 #16
0
 public RecordDAL(PetControlEntities context)
 {
     this.context = context;
 }
コード例 #17
0
 public VaccineDAL(PetControlEntities context)
 {
     this.context = context;
 }
コード例 #18
0
 public PetDAL(PetControlEntities context)
 {
     this.context = context;
 }