Ejemplo n.º 1
0
        public IActionResult Create(Student student)
        {
            if (!ModelState.IsValid)
            {
                return(View(student));
            }

            var newStudentId = _repository.AddStudent(student);

            return(RedirectToAction("Index", new { newStudentId }));
        }
Ejemplo n.º 2
0
        private void OnSave()
        {
            UpdateStudent(Student, _editingStudent);

            //Update Student Table
            if (EditMode)
            {
                _studentsRepository.UpdateStudent(_editingStudent);
            }
            else
            {
                _studentsRepository.AddStudent(_editingStudent);
            }

            //Update Contacts
            foreach (Contact contact in AddedContacts)
            {
                _contactsRepository.AddContact(contact);
            }
            foreach (Contact contact in DeletedContacts)
            {
                _contactsRepository.DeleteContact(contact.ContactID);
            }

            //Update Biometrics
            foreach (RelBiometric relBiometric in AddedRelBiometrics)
            {
                _relBiometricsRepository.AddRelBiometric(relBiometric);
            }
            foreach (Biometric biometric in DeletedBiometrics)
            {
                _relBiometricsRepository.DeleteRelBiometric(biometric.FingerID);
                _biometricsRepository.DeleteBiometric(biometric.FingerID);
            }

            //Update Groups
            #region Not used
            foreach (RelOrganization group in AddedGroups)
            {
                _relOrganizationsRepository.AddRelOrganization(group);
            }
            foreach (RelOrganization group in DeletedGroups)
            {
                _relOrganizationsRepository.DeleteRelOrganization(group.RelOrganizationID);
            }
            #endregion


            SelectedImage = null;
            Done();
        }
Ejemplo n.º 3
0
        public StudentTemplate AddStudent(StudentTemplate newStudent, int id)
        {
            Student stud = new Student();

            stud.SSN             = newStudent.SSN;
            stud.Name            = newStudent.Name;
            stud.StudentCourseID = id;

            var newStud = _repo.AddStudent(stud);

            StudentTemplate retVal = new StudentTemplate();

            retVal.SSN  = newStud.SSN;
            retVal.Name = newStud.Name;
            return(retVal);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Signup(SignupModel model)
        {
            try
            {
                var existing = await _repository.AuthenticateUserAsync(model.Username, model.Password);

                if (existing != null)
                {
                    return(BadRequest("Username in use"));
                }
                if (model.UserType.Equals("student"))
                {
                    Student student = new Student();
                    student.Username = model.Username;
                    student.Password = model.Password;
                    City cluj = new City();
                    cluj.CityId   = 1;
                    cluj.CityName = "Cluj";
                    student.City  = cluj;
                    Technology net = new Technology();
                    net.TechnologyId   = 1;
                    net.Interest       = ".Net";
                    student.Technology = net;

                    await _studentsRepository.AddStudent(student);
                }
                else
                {
                    Company company = new Company();
                    company.Username = model.Username;
                    company.Password = model.Password;
                    _companyRepository.Add(company);
                }

                return(Ok("User registered"));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Database failure"));
            }
        }
Ejemplo n.º 5
0
 public void AddStudent(StudentViewModel student)
 {
     _studentsRepo.AddStudent(_autoMapper.Map <Student>(student));
 }
        public async Task <IActionResult> AddStudent([FromBody] Student student)
        {
            await _studentsRepository.AddStudent(student);

            return(Created("student", student));
        }