Пример #1
0
 public void AddPackage(Package package)
 {
     using (var ctx = new CareManagmentDb())
     {
         ctx.Packages.Add(package);
         ctx.SaveChanges();
     }
 }
Пример #2
0
 public void AddRecipient(Recipient recipient)
 {
     using (var ctx = new CareManagmentDb())
     {
         ctx.Recipients.Add(recipient);
         ctx.SaveChanges();
     }
 }
Пример #3
0
 public void AddVolunteer(Volunteer volunteer)
 {
     using (var ctx = new CareManagmentDb())
     {
         ctx.Volunteers.Add(volunteer);
         ctx.SaveChanges();
     }
 }
Пример #4
0
 public void AddAdmin(Admin admin)
 {
     using (var ctx = new CareManagmentDb())
     {
         ctx.Admins.Add(admin);
         ctx.SaveChanges();
     }
 }
Пример #5
0
 public void UpdateDistribution(Distribution distribution)
 {
     using (var context = new CareManagmentDb())
     {
         var old = context.Distributions.Find(distribution.DistributionId);
         old.AdminId     = distribution.AdminId;
         old.VolunteerId = distribution.VolunteerId;
         old.IsDelivered = distribution.IsDelivered;
         old.Packages    = distribution.Packages;
         old.Date        = distribution.Date;
         context.SaveChanges();
     }
 }
Пример #6
0
        public void AddDistribution(Distribution distribution)
        {
            using (var ctx = new CareManagmentDb())
            {
                //distribution.Admin = null;
                //distribution.Volunteer = null;
                foreach (Package p in distribution.Packages)
                {
                    p.Recipient = null;
                }

                ctx.Distributions.Add(distribution);
                ctx.SaveChanges();
            }
        }
Пример #7
0
        public List <Distribution> GetAllDistributions(Func <Distribution, bool> predicate = null)
        {
            List <Distribution> result = new List <Distribution>();

            using (var context = new CareManagmentDb())
            {
                if (predicate == null)
                {
                    result = context.Distributions.Include(d => d.Admin).Include(d => d.Volunteer).ToList();
                }
                else
                {
                    result = context.Distributions.Include(d => d.Admin).Include(d => d.Volunteer).Where(predicate).ToList();
                }
            }
            return(result);
        }
Пример #8
0
        public List <Recipient> GetAllRecipients(Func <Recipient, bool> predicate = null)
        {
            List <Recipient> result = new List <Recipient>();

            using (var context = new CareManagmentDb())
            {
                if (predicate == null)
                {
                    result = context.Recipients.ToList();
                }
                else
                {
                    result = context.Recipients.Where(predicate).ToList();
                }
            }
            return(result);
        }
Пример #9
0
        public List <Admin> GetAllAdmins(Func <Admin, bool> predicate = null)
        {
            List <Admin> result = new List <Admin>();

            using (var context = new CareManagmentDb())
            {
                if (predicate == null)
                {
                    result = context.Admins.ToList();
                }
                else
                {
                    result = context.Admins.Where(predicate).ToList();
                }
            }
            return(result);
        }
Пример #10
0
        public List <Volunteer> GetAllVolunteers(Func <Volunteer, bool> predicate = null)
        {
            List <Volunteer> result = new List <Volunteer>();

            using (var context = new CareManagmentDb())
            {
                if (predicate == null)
                {
                    result = context.Volunteers.ToList();
                }
                else
                {
                    result = context.Volunteers.Where(predicate).ToList();
                }
            }
            return(result);
        }
Пример #11
0
        public List <Package> GetAllPackages(Func <Package, bool> predicate = null)
        {
            List <Package> result = new List <Package>();

            using (var context = new CareManagmentDb())
            {
                if (predicate == null)
                {
                    result = (from element in context.Packages.Include(s => s.Recipient).OfType <Package>()
                              select element).ToList();
                }
                else
                {
                    result = context.Packages.Include(s => s.Recipient).Where(predicate).ToList();
                }
            }
            return(result);
        }