Exemplo n.º 1
0
        public int AddMentorFromForm(MentorFormModel mentor)
        {
            var m = new Mentor();

            m.Age        = mentor.Age;
            m.Name       = mentor.Name;
            m.Surname    = mentor.Surname;
            m.StartDate  = DateTime.Parse(mentor.StartDate);
            m.Disability = Convert.ToByte(mentor.Disability);
            m.Gender     = mentor.Gender.ToString();
            m.Email      = mentor.Email;
            m.Phone      = mentor.Phone;
            m.C_Mentees  = mentor.Mentees;

            var AutoID = GetNextMentorID();

            mentorRepository.Add(m);

            foreach (string language in mentor.Languages)
            {
                var ml = new MentorLanguage();
                ml.MentorID = AutoID;
                System.Diagnostics.Debug.WriteLine(language.ToString());
                ml.LanguageID = Int32.Parse(language);
                mentorLanguagesRepository.Add(ml);
            }
            if (mentor.Nationalities != null)
            {
                foreach (string nationality in mentor.Nationalities)
                {
                    var prefNat = new MentorPreferences();
                    prefNat.MentorID      = AutoID;
                    prefNat.NationalityID = Int32.Parse(nationality);
                    mentorPreferencesRepository.Add(prefNat);
                }
            }
            return(AutoID);
        }
Exemplo n.º 2
0
 public IActionResult Post([FromBody] Mentor item)
 {
     _repository.Add(item);
     return(Ok("Record Added"));
 }