Пример #1
0
        private List <IntrestedDonorDModel> GetDonorDModels(int centerId, DateTime expectedDate)
        {
            var donorDModels     = new List <IntrestedDonorDModel>();
            var interestedDonors = _db.IDonors.Where(d => d.CollectionCentreId == centerId && d.AppointmentScheduled.Day.Equals(expectedDate.Day));
            var donors           = _db.Doners.ToList();

            foreach (var interestedDonor in interestedDonors)
            {
                var model = new IntrestedDonorDModel
                {
                    Id                     = interestedDonor.Id,
                    Name                   = donors.Where(d => d.Id == interestedDonor.Id).Select(d => d.Name).FirstOrDefault(),
                    ContactNumber          = interestedDonor.ContactNumber,
                    CollectionCentreId     = interestedDonor.CollectionCentreId,
                    AppointmentScheduled   = interestedDonor.AppointmentScheduled,
                    DonatedDate            = interestedDonor.DonatedDate,
                    DonorId                = interestedDonor.DonorId,
                    RepliedOn              = interestedDonor.RepliedOn,
                    SmsSentDate            = interestedDonor.SMSSentDate,
                    Status                 = interestedDonor.Status,
                    AppointmentChangedDate = null
                };
                donorDModels.Add(model);
            }
            return(donorDModels);
        }
Пример #2
0
        public void UpdateIntrestedDonor(IntrestedDonorDModel dModel)
        {
            var iDonor = _db.IDonors.FirstOrDefault(d => d.Id == dModel.Id);

            //iDonor.CollectionCentreId = dModel.ChangedCollectionCenter
            if (iDonor == null)
            {
                return;
            }
            if (dModel.AppointmentChangedDate != null)
            {
                iDonor.AppointmentScheduled = (DateTime)dModel.AppointmentChangedDate;
                iDonor.AppointmentScheduled.AddDays(-1);
            }

            _db.IDonors.Attach(iDonor);
            _db.Entry(iDonor).State = EntityState.Modified;
            _db.SaveChanges();
        }
 //api/dashboard/updatedonor
 public List <CollectionCenterDModel> PutUpdateDonor(IntrestedDonorDModel dModel)
 {
     _service.UpdateIntrestedDonor(dModel);
     return(_service.GetDashboardData());
 }