Esempio n. 1
0
 public static void UpdateUsersActive(long MotherId)
 {
     using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
     {
         var a = db.Users.FirstOrDefault(w => w.UserId == MotherId);
         a.Active = 0;
         db.SaveChanges();
     }
 }
 public static long PostServiceAndDayVolunteer(List <ServiceAndDaysToVolunteer> d)
 {
     using (var db = new EZER_LAYOLEDETEntities())
     {
         foreach (var item in d)
         {
             db.ServiceAndDaysToVolunteer.Add(item);
             db.SaveChanges();
             UserId = item.UserId;
         }
         return(UserId);
     }
 }
Esempio n. 3
0
 public static long AddBirth(Birth birth)
 {
     try
     {
         using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
         {
             var newBirth = db.Birth.Add(birth);
             db.SaveChanges();
             return(newBirth.UserId);
         }
     }
     catch
     {
         throw;
     }
 }
Esempio n. 4
0
 public static int UpdatePassword(Users u, string pass)
 {
     using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
     {
         var q2 = db.Users.FirstOrDefault(w => w.UserId == u.UserId);
         if (q2 == null)
         {
             return(0);
         }
         else
         {
             q2.Password = pass;
             return(db.SaveChanges());
         }
     }
 }
Esempio n. 5
0
 public static int AddUser(Users u)
 {
     try
     {
         using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
         {
             var q1 = db.Users.Add(u);
             db.SaveChanges();
             return((int)q1.UserId);
         }
     }
     catch
     {
         throw;
     }
 }
 public static void AddServiceVolunteerToBirth(ServiceVolunteerToBirth s)
 {
     try
     {
         using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
         {
             var q1 = db.ServiceVolunteerToBirth.Add(s);
             db.SaveChanges();
             // return q1.MotherId;
         }
     }
     catch
     {
         throw;
     }
 }
Esempio n. 7
0
        public static int UpdateUsers(Users u)
        {
            try
            {
                using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
                {
                    var q2 = db.Users.FirstOrDefault(w => w.UserId == u.UserId);
                    if (q2 == null)
                    {
                        return(0);
                    }
                    else
                    {
                        //  db.Users.Attach(u);
                        // db.Entry(u).State = EntityState.Modified;


                        q2.UserId = u.UserId;

                        q2.RoleId     = u.RoleId;
                        q2.FirstName  = u.FirstName;
                        q2.LastName   = u.LastName;
                        q2.Password   = u.Password;
                        q2.Email      = u.Email;
                        q2.Phone      = u.Phone;
                        q2.Address    = u.Address;
                        q2.NumOfHouse = u.NumOfHouse;
                        q2.Locality   = u.Locality;
                        q2.BirthDate  = u.BirthDate;
                        q2.Active     = u.Active;

                        return(db.SaveChanges());
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 8
0
        public static long AddMother(Mother mother, Birth birth, Kosher kosher1 = null, Kosher kosher2 = null, Kosher kosher3 = null)
        {
            try
            {
                using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
                {
                    var user = db.Users.Add(mother.Users);
                    //var newKosher1 = db.Kosher.Add(kosher1);
                    //var newKosher2 = db.Kosher.Add(kosher2);
                    //var newKosher3 = db.Kosher.Add(kosher3);

                    var newMother = db.Mother.Add(mother);

                    //db.SaveChanges();
                    var newBirth = db.Birth.Add(birth);
                    newMother.Birth.Add(newBirth);


                    //newMother.Users = user;
                    //newMother.UserId = user.UserId;
                    //newMother.Kosher1 = newKosher1.KosherId;
                    //newMother.Kosher2 = newKosher2.KosherId;
                    //newMother.Kosher3 = newKosher3.KosherId;
                    //newMother.Kosher = newKosher1;
                    //newMother.Kosher4 = newKosher2;
                    //newMother.Kosher5 = newKosher3;


                    db.SaveChanges();

                    return(newMother.UserId);
                }
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }
Esempio n. 9
0
 public static int DeleteUser(int id)
 {
     try
     {
         using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
         {
             var q3 = db.Users.FirstOrDefault(w => w.UserId == id);
             if (q3 == null)
             {
                 return(0);
             }
             else
             {
                 db.Users.Remove(q3);
                 db.SaveChanges();
                 return(1);
             }
         }
     }
     catch
     {
         throw;
     }
 }
        public static int UpdateRequest(long ServiceManagmentId)
        {
            try
            {
                using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
                {
                    var q2 = db.ServiceManagementToBirth.FirstOrDefault(w => w.ServiceManagementId == ServiceManagmentId);
                    if (q2 == null)
                    {
                        return(0);
                    }
                    else
                    {
                        q2.StatusRequest = 0;

                        return(db.SaveChanges());
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 11
0
        public static int AddVolunteer(Users userToAdd)
        {
            try
            {
                using (EZER_LAYOLEDETEntities db = new EZER_LAYOLEDETEntities())
                {
                    var user           = db.Users.Add(userToAdd);
                    var volunteerToAdd = new Volunteer
                    {
                        UserId = user.UserId
                    };
                    var volunteer = db.Volunteer.Add(volunteerToAdd);

                    //var Day = db.DaysToVolunteer.Add(v.DaysToVolunteer);
                    //var Service = db.ServiceToVolunteer.Add(v.ServiceToVolunteer);
                    db.SaveChanges();
                    return((int)user.UserId);
                }
            }
            catch
            {
                throw;
            }
        }