示例#1
0
        public static BloodDonorViewModel UpdateBloodDonor(BloodDonorViewModel donor)
        {
            var        db       = new bloodbankDbContext();
            BloodDonor oldDonor = db.BloodDonors.Where(e => e.RegNo == donor.RegNo).FirstOrDefault();
            User       oldUser  = db.Users.Where(e => e.BloodDonorId == oldDonor.Id).FirstOrDefault();

            oldDonor.Name             = donor.Name;
            oldDonor.NickName         = donor.NickName;
            oldDonor.Mobile           = donor.Mobile;
            oldDonor.EmergencyContact = donor.EmergencyContact;
            oldDonor.Comment          = donor.Comment;
            oldDonor.Division         = donor.Division;
            oldDonor.LastDonatedDate  = donor.LastDonatedDate;
            oldDonor.BloodGroup       = donor.BloodGroup;
            oldDonor.Email            = donor.Email;

            if (donor.Password != null)
            {
                oldUser.Password = PasswordHash.Hash(donor.Password);
            }


            db.Entry(oldDonor).State = System.Data.Entity.EntityState.Modified;
            db.Entry(oldUser).State  = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(donor);
        }
示例#2
0
        public static BloodDonor ApproveDonor(int id)
        {
            var        db         = new bloodbankDbContext();
            var        blooddonor = new BloodDonor();
            BloodDonor bloodDonor = db.BloodDonors.Find(id);

            if (bloodDonor == null)
            {
                return(null);
            }

            bloodDonor.IsVerified      = true;
            db.Entry(bloodDonor).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(bloodDonor);
        }
示例#3
0
        public static BloodDonor LastDonationDateUpdate(int id, DateTime date)
        {
            var        db         = new bloodbankDbContext();
            var        blooddonor = new BloodDonor();
            BloodDonor bloodDonor = db.BloodDonors.Find(id);

            if (bloodDonor == null)
            {
                return(null);
            }

            bloodDonor.LastDonatedDate = date;
            bloodDonor.HasDonated      = true;
            db.Entry(bloodDonor).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            return(bloodDonor);
        }