コード例 #1
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;
            }
        }