Пример #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 AddAdmin(Admin admin)
 {
     using (var ctx = new CareManagmentDb())
     {
         ctx.Admins.Add(admin);
         ctx.SaveChanges();
     }
 }
Пример #4
0
 public void AddVolunteer(Volunteer volunteer)
 {
     using (var ctx = new CareManagmentDb())
     {
         ctx.Volunteers.Add(volunteer);
         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();
            }
        }