Beispiel #1
0
 public async Task <IActionResult> Create(Instructor instructor)
 {
     if (ModelState.IsValid)
     {
         _instructorRepository.Create(instructor);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(instructor));
 }
        public async Task <IActionResult> Post([FromBody] Instructor instructor)
        {
            DateTime createDate = DateTime.Now;

            instructor.CreatedDate = createDate;
            await _instructorRepository.Create(instructor);

            return(new OkObjectResult(instructor));
        }
Beispiel #3
0
        public InstructorDto Create(InstructorDto entity)
        {
            using (_instructorRepository)
            {
                var entityToCreate = entity.ConvertToInstructorDbModel();

                _instructorRepository.Create(entityToCreate);
                _instructorRepository.SaveChanges();

                return(entityToCreate.ConvertToInstructorDto());
            }
        }
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            _repository.Create(new Instructor
            {
                FirstName = txtFirstName.Text.Trim(),
                LastName  = txtLastName.Text.Trim(),
                Phone     = txtPhone.Text.Trim()
            });

            SharedViewLogic.LoadInstructors(_dgvInstructors, _repository);

            Close();
        }
Beispiel #5
0
        public async Task <Response> Create(Instructor item)
        {
            Response response = new Response();

            try
            {
                response = await _InstructorRepo.Create(item);

                return(response);
            }
            catch (Exception e)
            {
                StringBuilder sb = new StringBuilder();
                log.Error(sb.AppendLine(e.Message).AppendLine(e.StackTrace).ToString());
                response.ErrorList.Add("Error on create Instructor");
                response.Success = false;
                return(response);
            }
        }
        public void Post(InstructorDTO value)
        {
            Instructor model = new Instructor()
            {
                LastName  = value.LastName,
                FirstName = value.FirstName,
            };

            IInstructorRepository.Create(model);

            // trebuie sa introducem si in tabela de intersectie
            for (int i = 0; i < value.SpecializationId.Count; i++)
            {
                InstructorSpecialization InstructorSpecialization = new InstructorSpecialization()
                {
                    InstructorId     = model.Id,
                    SpecializationId = value.SpecializationId[i]
                };
                IInstructorSpecializationRepository.Create(InstructorSpecialization);
            }
        }