Ejemplo n.º 1
0
        public async Task <int> CreateUserAsync(User User)
        {
            using (var db = new DonorsDBContext())
            {
                await db.Users.AddAsync(User);

                return(await db.SaveChangesAsync());
            }
        }
Ejemplo n.º 2
0
        public async Task <int> CreateDonorProfileAsync(Donor Donor)
        {
            using (var db = new DonorsDBContext())
            {
                await db.Donors.AddAsync(Donor);

                return(await db.SaveChangesAsync());
            }
        }
Ejemplo n.º 3
0
        public async Task <int> AddDonationAsync(Donation Donation)
        {
            using (var db = new DonorsDBContext())
            {
                await db.Donations.AddAsync(Donation);

                return(await db.SaveChangesAsync());
            }
        }
Ejemplo n.º 4
0
        public async Task <int> CreateCampaignProfileAsync(Campaign Campaign)
        {
            using (var db = new DonorsDBContext())
            {
                await db.Campaigns.AddAsync(Campaign);

                return(await db.SaveChangesAsync());
            }
        }
Ejemplo n.º 5
0
 public async Task <int> UpdateDonationAsync(Donation Donation)
 {
     using (var db = new DonorsDBContext())
     {
         var _donation = db.Donations.FirstOrDefaultAsync(x => x.DonationID == Donation.DonationID);
         if (_donation != null)
         {
             db.Donations.Update(Donation);
             return(await db.SaveChangesAsync());
         }
     }
     return(0);
 }
Ejemplo n.º 6
0
 public async Task <int> UpdateDonorProfileAsync(Donor Donor)
 {
     using (var db = new DonorsDBContext())
     {
         var _donor = db.Donors.FirstOrDefaultAsync(x => x.DonorID == Donor.DonorID);
         if (_donor != null)
         {
             db.Donors.Update(Donor);
             return(await db.SaveChangesAsync());
         }
     }
     return(0);
 }
Ejemplo n.º 7
0
        public async Task <int> DeleteDonationAsync(Guid DonationID)
        {
            using (var db = new DonorsDBContext())
            {
                var _donation = await db.Donations.FirstOrDefaultAsync(x => x.DonationID == DonationID);

                if (_donation != null)
                {
                    db.Donations.Remove(_donation);
                    return(await db.SaveChangesAsync());
                }
            }
            return(0);
        }
Ejemplo n.º 8
0
        public async Task <int> DeleteDonorProfileAsync(Guid DonorID)
        {
            using (var db = new DonorsDBContext())
            {
                var _donor = await db.Donors.Include(x => x.Person).FirstOrDefaultAsync(x => x.DonorID == DonorID);

                if (_donor != null)
                {
                    _donor.Person.IsDeleted = true;
                    return(await db.SaveChangesAsync());
                }
            }
            return(0);
        }
Ejemplo n.º 9
0
        public async Task <int> DeleteCampaignProfileAsync(Guid CampaignID)
        {
            using (var db = new DonorsDBContext())
            {
                var _campaign = await db.Campaigns.FirstOrDefaultAsync(x => x.CampaignID == CampaignID);

                if (_campaign != null)
                {
                    db.Campaigns.Remove(_campaign);
                    return(await db.SaveChangesAsync());
                }
            }
            return(0);
        }
Ejemplo n.º 10
0
        public async Task <int> DeleteUserAsync(Guid UserID)
        {
            using (var db = new DonorsDBContext())
            {
                var _user = await db.Users.Include(x => x.Person).FirstOrDefaultAsync(x => x.UserID == UserID);

                if (_user != null)
                {
                    _user.Person.IsDeleted = true;
                    _user.IsActive         = false;
                    _user.DateUpdated      = DateTime.Now.ToUniversalTime();
                    return(await db.SaveChangesAsync());
                }
            }
            return(0);
        }
Ejemplo n.º 11
0
        public async Task <int> UpdateUserAsync(User User)
        {
            using (var db = new DonorsDBContext())
            {
                var _user = await db.Users.Include(x => x.Person).Include(x => x.Person.Contacts).Include(x => x.Person.Addresses).FirstOrDefaultAsync(x => x.UserID == User.UserID);

                if (_user != null)
                {
                    _user.UserName           = User.UserName;
                    _user.Person.FirstName   = User.Person.FirstName;
                    _user.Person.MiddleName  = User.Person.MiddleName;
                    _user.Person.Gender      = User.Person.Gender;
                    _user.Person.DOB         = User.Person.DOB;
                    _user.Person.DisplayName = User.Person.DisplayName;

                    db.Users.Update(_user);

                    var _cont = await db.Contacts.FirstOrDefaultAsync(x => x.PersonID == User.PersonID);

                    if (_cont != null)
                    {
                        var __cont = User.Person.Contacts.FirstOrDefault();
                        _cont.Phone = __cont.Phone;
                        _cont.Email = __cont.Email;
                        db.Contacts.Update(_cont);
                    }
                    var _addr = await db.Addresses.FirstOrDefaultAsync(x => x.PersonID == User.PersonID);

                    if (_addr != null)
                    {
                        var __addr = User.Person.Addresses.FirstOrDefault();
                        _addr.Address1 = __addr.Address1;
                        _addr.Address2 = __addr.Address2;
                        _addr.City     = __addr.City;
                        _addr.State    = __addr.State;
                        _addr.ZIPCode  = __addr.ZIPCode;
                        db.Addresses.Update(_addr);
                    }
                    return(await db.SaveChangesAsync());
                }
            }
            return(0);
        }