Example #1
0
        public void CreateSchool(string userId, string schoolName, string schoolClass, string schoolCity, string houseNumber, string postalCode,
                                 string counselorFirstName, string counselorLastName, string schoolStreet, string schoolPhone)
        {
            ApplicationDbContext context = new ApplicationDbContext();

            UsersSchools modelSchool = new UsersSchools
            {
                UserId      = userId,
                Name        = schoolName,
                Class       = schoolClass,
                City        = schoolCity,
                PostalCode  = postalCode,
                HouseNumber = houseNumber,
                Street      = schoolStreet,
                Phone       = schoolPhone
            };

            context.UsersSchools.Add(modelSchool);

            if (!String.IsNullOrEmpty(counselorFirstName))
            {
                UsersCounselor modelCounselor = new UsersCounselor
                {
                    UserId    = userId,
                    FirstName = counselorFirstName,
                    LastName  = counselorLastName
                };

                context.UsersCounselor.Add(modelCounselor);
            }

            context.SaveChanges();
            context.Dispose();
        }
Example #2
0
        public bool ChangeUserCounselor(string userId, string firstName, string lastName)
        {
            UsersCounselor model = new UsersCounselor
            {
                UserId    = userId,
                FirstName = firstName,
                LastName  = lastName
            };

            bool result = _userRepository.EditUserCounselor(model);

            return(result);
        }
Example #3
0
        public bool AddUserCounselot(string userId, string firstName, string lastName)
        {
            UsersCounselor userCounselorModel = new UsersCounselor
            {
                UserId    = userId,
                FirstName = firstName,
                LastName  = lastName
            };

            bool result = _userRepository.AddUserCounselor(userCounselorModel);

            return(result);
        }
Example #4
0
        public bool AddUserCounselor(UsersCounselor model)
        {
            try
            {
                _context.UsersCounselor.Add(model);
                _context.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #5
0
        public bool EditUserCounselor(UsersCounselor model)
        {
            try
            {
                var dbModel = _context.UsersCounselor
                              .Select(x => x)
                              .Where(x => x.UserId == model.UserId)
                              .FirstOrDefault();

                dbModel.FirstName = model.FirstName;
                dbModel.LastName  = model.LastName;

                _context.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }