public Dto.Stats GetSystemStats() { var dal = new CpoDataLayer(); var stats = dal.GetSystemStats(); if (stats != null) { return new Dto.Stats { TotalDonations = stats.Donations, TotalFoodBanks = stats.Centers, TotalVolunteers = stats.Volunteers }; } return null; }
/// <summary> /// Gets food banks. /// </summary> /// <param name="offset">Return data starting point.</param> /// <param name="limit">Total number of food banks that should be returned.</param> /// <returns></returns> public List<Dto.FoodBank> GetFoodBanks(int offset = 0, int limit = 5) { var dal = new CpoDataLayer(); var centers = dal.GetCenters(offset, limit); return centers.Select(center => new Dto.FoodBank { Addr1 = center.Address1, Addr2 = center.Address2, City = center.City, Created = center.DateCreated, Id = center.CenterId, Name = center.Name, Postal = center.ZipCode, State = center.State, DonationCount = center.DonationCount, VolunteerCount = center.VolunteerCount }).ToList(); }
public Dto.FoodBank GetFoodBank(int centerId) { var dal = new CpoDataLayer(); var center = dal.GetCenter(centerId); if (center != null) { return new Dto.FoodBank { Addr1 = center.Address1, Addr2 = center.Address2, City = center.City, Created = center.DateCreated, Id = center.CenterId, Name = center.Name, Postal = center.ZipCode, State = center.State, DonationCount = center.DonationCount, VolunteerCount = center.VolunteerCount }; } return null; }
public bool UpdateVolunteer(Dto.Volunteer volunteer) { var vol = new chrisparkeronline.com.Dal.DataModel.Volunteer { FullName = volunteer.Name, DOB = volunteer.DateOfBirth, CenterId = volunteer.FoodBankId, VolunteerId = volunteer.Id }; var dal = new CpoDataLayer(); return dal.UpdateVolunteer(vol); }
public bool DeleteVolunteer(int id) { var dal = new CpoDataLayer(); return dal.DeleteVolunteer(id); }
public Dto.Volunteer CreateVolunteer(Dto.Volunteer newVolunteer) { var value = new chrisparkeronline.com.Dal.DataModel.Volunteer { CenterId = newVolunteer.FoodBankId, DOB = newVolunteer.DateOfBirth, FullName = newVolunteer.Name, DateCreated = DateTime.Now }; var dal = new CpoDataLayer(); var addedVolunteer = dal.CreateVolunteer(value); if (addedVolunteer != null) { return new Dto.Volunteer { FoodBankId = addedVolunteer.CenterId, DateOfBirth = addedVolunteer.DOB, Name = addedVolunteer.FullName, Id = addedVolunteer.VolunteerId, Created = addedVolunteer.DateCreated }; } return null; }
public Dto.Volunteer GetVolunteer(int volunteerId) { var dal = new CpoDataLayer(); var volunteer = dal.GetVolunteer(volunteerId); if (volunteer != null) { return new Dto.Volunteer { DateOfBirth = volunteer.DOB, Name = volunteer.FullName, Created = volunteer.DateCreated, Id = volunteer.VolunteerId, FoodBankId = volunteer.CenterId, FoodBankName = volunteer.CenterName }; } return null; }
public List<Dto.Volunteer> GetVolunteers(int startPosition = 0, int total = 10) { var dal = new CpoDataLayer(); var volunteers = dal.GetVolunteers(startPosition, total); return volunteers.Select(volunteer => new Dto.Volunteer { DateOfBirth = volunteer.DOB, Name = volunteer.FullName, Created = volunteer.DateCreated, Id = volunteer.VolunteerId, FoodBankId = volunteer.CenterId, FoodBankName = volunteer.CenterName }).ToList(); }
public Dto.FoodBank CreateFoodBank(Dto.FoodBank newBank) { var newCenter = new Center { Address1 = newBank.Addr1, Address2 = newBank.Addr2, City = newBank.City, DateCreated = DateTime.Now, //CenterId = newBank.Id, Name = newBank.Name, ZipCode = newBank.Postal, State = newBank.State }; var dal = new CpoDataLayer(); var addedCenter = dal.CreateCenter(newCenter); if (addedCenter != null) { return new Dto.FoodBank { Addr1 = addedCenter.Address1, Addr2 = addedCenter.Address2, City = addedCenter.City, Created = addedCenter.DateCreated, Id = addedCenter.CenterId, Name = addedCenter.Name, Postal = addedCenter.ZipCode, State = addedCenter.State }; } return null; }
public Dto.Donation CreateDonation(Dto.Donation newDonation) { var value = new chrisparkeronline.com.Dal.DataModel.Donation { CenterId = newDonation.FoodBankId, VolunteerId = newDonation.VolunteerId, Item = newDonation.Item, Quality = newDonation.Quality, Quantity = newDonation.Quantity, DonatedDate = DateTime.Now }; var dal = new CpoDataLayer(); var addedDonation = dal.CreateDonation(value); if (addedDonation != null) { return new Dto.Donation { Id = addedDonation.DonationId, Item = addedDonation.Item, Quality = addedDonation.Quality, Quantity = addedDonation.Quantity, Created = addedDonation.DonatedDate.Value, VolunteerId = addedDonation.VolunteerId, FoodBankId = addedDonation.CenterId, }; } return null; }
public Dto.Donation GetDonation(int donationId) { var dal = new CpoDataLayer(); var donation = dal.GetDonation(donationId); if (donation != null) { return new Dto.Donation { Item = donation.Item, Quality = donation.Quality, Quantity = donation.Quantity, Created = donation.DonatedDate.Value, Id = donation.DonationId, VolunteerId = donation.VolunteerId, FoodBankId = donation.CenterId, FoodBankName = donation.CenterName, VolunteerName = donation.VolunteerName }; } return null; }
public List<Dto.Donation> GetDonations(int startPosition = 0, int total = 10) { var dal = new CpoDataLayer(); var donations = dal.GetDonations(startPosition, total); return donations.Select(donation => new Dto.Donation { Item = donation.Item, Quality = donation.Quality, Quantity = donation.Quantity, Created = donation.DonatedDate.Value, Id = donation.DonationId, VolunteerId = donation.VolunteerId, FoodBankId = donation.CenterId, FoodBankName = donation.CenterName, VolunteerName = donation.VolunteerName }).ToList(); }
public bool UpdateFoodBank(Dto.FoodBank bank) { var center = new Center { Address1 = bank.Addr1, Address2 = bank.Addr2, City = bank.City, CenterId = bank.Id, Name = bank.Name, ZipCode = bank.Postal, State = bank.State }; var dal = new CpoDataLayer(); return dal.UpdateCenter(center); }
public bool DeleteFoodBank(int id) { var dal = new CpoDataLayer(); return dal.DeleteCenter(id); }
public void CreateRequestLogEntry(int requestId, string httpStatus, string uri, string method, string host) { var dal = new CpoDataLayer(); dal.InsertRequestLogEntry(requestId, httpStatus, uri, method, host); }
public bool DeleteDonation(int id) { var dal = new CpoDataLayer(); return dal.DeleteDonation(id); }
public bool UpdateDonation(Dto.Donation donation) { var don = new Donation { Item = donation.Item, DonationId = donation.Id, Quality = donation.Quality, Quantity = donation.Id, CenterId = donation.FoodBankId, VolunteerId = donation.VolunteerId }; var dal = new CpoDataLayer(); return dal.UpdateDonation(don); }
public List<Dto.Donation> GetFoodBankDonations(int centerId) { var dal = new CpoDataLayer(); var donations = dal.GetCenterDonations(centerId); return donations.Select(donation => new Dto.Donation { Item = donation.Item, Quality = donation.Quality, Quantity = donation.Quantity, Created = donation.DonatedDate.Value, Id = donation.DonationId, }).ToList(); }
public List<Dto.Volunteer> GetFoodBankVolunteers(int centerId) { var dal = new CpoDataLayer(); var volunteers = dal.GetCenterVolunteers(centerId); return volunteers.Select(volunteer => new Dto.Volunteer { DateOfBirth = volunteer.DOB, Name = volunteer.FullName, Created = volunteer.DateCreated, Id = volunteer.VolunteerId, FoodBankId = volunteer.CenterId }).ToList(); }