Ejemplo n.º 1
0
 public void DeleteResidentWithVisitors(int residentId)
 {
     using (var context = new CareContext()) {
         Resident res = context.Residents.Find(residentId);
         context.Residents.Remove(res);
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void Delete(Car entity)
 {
     using (CareContext context = new CareContext())
     {
         var deletedEntity = context.Entry(entity);
         deletedEntity.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void Update(Car entity)
 {
     using (CareContext context = new CareContext())
     {
         var updatedEntity = context.Entry(entity);
         updatedEntity.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public void Add(Car entity)
 {
     using (CareContext context = new CareContext())
     {
         var addedEntity = context.Entry(entity);
         addedEntity.State = EntityState.Added;
         context.SaveChanges();
     }
 }
Ejemplo n.º 5
0
        public Resident UpdateNameResident(int residentId, string preName, string lastName)
        {
            Resident resident = new Resident();

            using (var context = new CareContext()) {
                try {
                    resident = context.Residents.Find(residentId);

                    if (!resident.Prename.Equals(preName) && !String.IsNullOrEmpty(preName))
                    {
                        resident.Prename = preName;
                    }
                    if (!resident.LastName.Equals(lastName) && !String.IsNullOrEmpty(lastName))
                    {
                        resident.LastName = lastName;
                    }

                    context.SaveChanges();
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }
            return(resident);
        }