public static Donor UpdateDonorPassword(int id, Donor c)
        {
            try
            {
                Donor c0 = dataContext.Donors.Where(x => x.Id == id).SingleOrDefault();

                if (c.password != null)
                {
                    c0.password = c.password;
                }


                dataContext.SaveChanges();
                return(GetDonor(id));
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        public static string getSecurityQuestionByMail(string email)
        {
            List <Donor> lc    = GetAllDonors();
            Donor        donor = lc.Where(x => x.email == email).FirstOrDefault();

            List <Requestor> lr        = RequestorRepository.GetAllRequestors();
            Requestor        requestor = lr.Where(x => x.email == email).FirstOrDefault();

            if (donor != null || requestor != null)
            {
                if (donor != null)
                {
                    return(donor.securityQuestion);
                }
                else
                {
                    return(requestor.securityQuestion);
                }
            }
            return(null);
        }
        public static Donor InsertDonor(Donor c)
        {
            try
            {
                if (c.ammountGiven == null)
                {
                    c.ammountGiven = 0;
                }

                if (c.points == null)
                {
                    c.points = 0;
                }
                dataContext.Donors.Add(c);
                dataContext.SaveChanges();
                dataContext = new RobaSegonaMaEntities(false);
                return(GetDonor(c.Id));
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        public static string CanLoginBoth(Donor a)
        {
            dataContext = new RobaSegonaMaEntities(false);
            List <Donor> lc    = GetAllDonors();
            Donor        donor = lc.Where(x => x.password == a.password && x.email == a.email && x.active == true).FirstOrDefault();

            List <Requestor> lr = RequestorRepository.GetAllRequestors();
            // Requestor requestor = lr.Where(x => x.password == a.password && x.email == a.email && x.active == true && x.Status.status1.ToLower().Equals("activated")).FirstOrDefault();
            Requestor requestor = lr.Where(x => x.password == a.password && x.email == a.email && x.active == true && x.Status_Id == 2).FirstOrDefault();

            if (donor != null || requestor != null)
            {
                if (donor != null)
                {
                    return("true-" + "Donor-" + donor.Id);
                }
                else
                {
                    return("true-" + "Requestor-" + requestor.Id);
                }
            }
            return("false");
        }
Beispiel #5
0
        public static List <Reward> getAvailableRewardsDonor(int donorId)
        {
            dataContext = new RobaSegonaMaEntities();

            List <Reward> lc = dataContext.Rewards.ToList();
            List <Reward> lr = new List <Reward>();

            foreach (Reward reward in lc)
            {
                if (reward.Donors == null)
                {
                    lr.Add(reward);
                    continue;
                }
                Donor d = reward.Donors.Where(x => x.Id == donorId).FirstOrDefault();
                if (d == null)
                {
                    lr.Add(reward);
                }
            }


            return(lr);
        }
        public static Donor UpdateDonor(int id, Donor c)
        {
            try
            {
                Donor c0 = dataContext.Donors.Where(x => x.Id == id).SingleOrDefault();
                if (c.name != null)
                {
                    c0.name = c.name;
                }
                if (c.lastName != null)
                {
                    c0.lastName = c.lastName;
                }
                if (c.birthDate != null)
                {
                    c0.birthDate = c.birthDate;
                }
                if (c.gender != null)
                {
                    c0.gender = c.gender;
                }
                if (c.password != null)
                {
                    c0.password = c.password;
                }
                if (c.email != null)
                {
                    c0.email = c.email;
                }
                if (c.securityAnswer != null)
                {
                    c0.securityAnswer = c.securityAnswer;
                }
                if (c.securityQuestion != null)
                {
                    c0.securityQuestion = c.securityQuestion;
                }
                if (c.dateCreated != null)
                {
                    c0.dateCreated = c.dateCreated;
                }
                if (c.active != null)
                {
                    c0.active = c.active;
                }
                if (c.picturePath != null)
                {
                    c0.picturePath = c.picturePath;
                }
                if (c.ammountGiven != null)
                {
                    c0.ammountGiven = c.ammountGiven;
                }
                if (c.Language != null)
                {
                    c0.Language = c.Language;
                }
                if (c.dni != null)
                {
                    c0.dni = c.dni;
                }
                if (c.points != null)
                {
                    c0.points = c.points;
                }



                dataContext.SaveChanges();
                Donor newDonor = GetDonor(id);
                dataContext = new RobaSegonaMaEntities(false);
                return(newDonor);
            }
            catch (Exception e)
            {
                return(null);
            }
        }