public void ItWorks()
        {
            Speaker speaker = _speakerService.AddSpeaker("Иван", "Иванов", "Иванович");

            _speakerRepository.Delete(speaker);

            Assert.True(true);
        }
예제 #2
0
        public IActionResult AddSpeaker(Speaker speaker)
        {
            var result = _speakerService.AddSpeaker(speaker);

            if (result.IsSuccess)
            {
                return(Ok(JsonSerializer.Serialize(result.Message)));
            }
            else
            {
                return(BadRequest(JsonSerializer.Serialize(result.Message)));
            }
        }
예제 #3
0
 public void AddSpeaker_InvalidName(string firstName)
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         _speakerService
         .AddSpeaker(
             firstName,
             "Иванов",
             "Иванович");
     });
 }
        public ActionResult Create(SpeakersViewModel model)
        {
            if (ModelState.IsValid)
            {
                Speakers speaker = new Speakers();
                speaker.InjectFrom(model);
                var speakerToCreate = speakerService.AddSpeaker(speaker);


                if (speakerToCreate == null)
                {
                    ModelState.AddModelError("Name", "Speaker name must be unique!");
                    return(View(model));
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public IActionResult Create(CreateSpeakerForm form)
        {
            if (!ModelState.IsValid)
            {
                return(View(form));
            }

            _speakerService.AddSpeaker(
                form.FirstName,
                form.Surname,
                form.Patronymic,
                form.University,
                form.Faculty,
                form.Group,
                form.Course);

            Speaker speaker = _speakerService.GetByName(
                form.FirstName,
                form.Surname,
                form.Patronymic);

            return(RedirectToAction("View", new { id = speaker.Id }));
        }
 public IActionResult AddSpeaker([FromBody] AddSpeakerModel speaker)
 {
     _speakerService.AddSpeaker(speaker.Name, speaker.Description);
     return(CreatedAtAction(nameof(GetSpeakers), null));
 }