/// <summary>
        /// Creates BloodDonor profile
        /// </summary>
        /// <param name="Donorfirstname"></param>
        /// <param name="Donorlastname"></param>
        /// <param name="Donorgender"></param>
        /// <param name="Donorage"></param>
        /// <param name="groupType"></param>
        /// <param name="rHfactorType"></param>
        /// <param name="emailAddress"></param>
        /// <returns> New Blood Donor profile</returns>
        /// <exception cref="System.ArgumentNullException"/>
        ///<exception cref="System.NotImplementedException"/>

        public static BloodDonor CreateBloodDonor(string Donorfirstname,
                                                  string Donorlastname, GenderType Donorgender,
                                                  int Donorage, BloodGroupType groupType,
                                                  RHfactorType rHfactorType,
                                                  string emailAddress)
        {
            if (String.IsNullOrEmpty(Donorfirstname) ||
                String.IsNullOrWhiteSpace(Donorfirstname))
            {
                throw new ArgumentNullException("Donorfirstname", "Donorfirstname cannot be Empty");
            }
            if (Donorage < 17)
            {
                throw new ArgumentOutOfRangeException("Donorage", "Sorry Minimum Donorage requirements in 17");
            }

            var blooddonor = new BloodDonor
            {
                DonorFirstName = Donorfirstname,
                DonorLastName  = Donorlastname,
                TypeofGender   = Donorgender,
                DonorAge       = Donorage,
                BloodGroup     = groupType,
                RHFactor       = rHfactorType,
                EmailAddress   = emailAddress
            };

            db.BloodDonors.Add(blooddonor);
            db.SaveChanges();
            return(blooddonor);
        }
Beispiel #2
0
        public static BloodDonor CreateBloodDonor(string Donorname,
                                                  int Donorage, BloodGroupType groupType,
                                                  RHfactorType rHfactorType, int Blooddonation)
        {
            var BloodDonor = new BloodDonor
            {
                DonorName  = Donorname,
                DonorAge   = Donorage,
                BloodGroup = groupType,
                RHFactor   = rHfactorType,
            };

            if (Donorage > 18)
            {
                BloodDonor.BloodDonation(Blooddonation);
            }
            return(BloodDonor);
        }