public async Task <ActionResult> CrearEspecialidad(CreateSpeciality createSpeciality)
        {
            using (var client = new HttpClient())
            {
                var ck = ControllerContext.HttpContext.Request.Cookies["Token"];
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ck);
                client.BaseAddress = new Uri("https://localhost:44349");
                var postTask = await client.PostAsJsonAsync <CreateSpeciality>("api/SpecialitiesCatalog", createSpeciality);

                if (postTask.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Especialidades"));
                }
                ModelState.AddModelError(string.Empty, "Server Error. Please contact administrator.");
                return(View("CrearEspecialidad"));
            }
        }
Esempio n. 2
0
        public async Task CreateSpeciality(CreateSpeciality request)
        {
            var faculty = unitOfWork.SpecialityRepository.GetFaculty(request.FucaltyName);

            Speciality speciality = new Speciality
            {
                Name              = request.SpecialityName,
                Description       = request.Description,
                BudgetPlaceNumber = request.BudgetPlaceNumber,
                PaidPlaceNumber   = request.PaidPlaceNumber,
                testNeeded1       = request.TestNeeded1,
                testNeeded2       = request.TestNeeded2,
                testNeeded3       = request.TestNeeded3,
                Faculty           = faculty,
                FacultyId         = faculty.FacultyId
            };

            await unitOfWork.SpecialityRepository.CreateAsync(speciality);

            await unitOfWork.Commit();
        }
Esempio n. 3
0
        public async Task <IActionResult> CreateSpeciality(CreateSpeciality speciality)
        {
            await AdministratorService.CreateSpeciality(speciality);

            ViewBag.Faculties = await this.AdministratorService.GetFaculties(
                await this.AdministratorService.GetUniversityId(User.Identity.Name));

            _log.LogInformation("Created Speciality");

            await this.HubContext.Clients.All.SendAsync("CreateSpeciality",
                                                        speciality.FucaltyName,
                                                        speciality.SpecialityName,
                                                        speciality.BudgetPlaceNumber,
                                                        speciality.PaidPlaceNumber,
                                                        speciality.TestNeeded1,
                                                        speciality.TestNeeded2,
                                                        speciality.TestNeeded3
                                                        );

            return(View());
        }
Esempio n. 4
0
        public async void CreateSpeciality_SaveChanges_ShouldInvokesOnce()
        {
            //arrange

            var faculty = new Faculty
            {
                Name = "English",
            };


            var mockUnitOfWork = new Mock <IUnitOfWork>();

            var specialityRepository = new Mock <ISpecialityRepository>();

            mockUnitOfWork.Setup(x => x.SpecialityRepository).Returns(specialityRepository.Object);
            specialityRepository.Setup(x => x.GetFaculty(It.IsAny <string>())).Returns(faculty);

            var administratorService = new AdministratorService(mockUnitOfWork.Object);
            var createSpeciality     = new CreateSpeciality()
            {
                SpecialityName    = "la",
                Description       = "la",
                BudgetPlaceNumber = 100,
                PaidPlaceNumber   = 100,
                TestNeeded1       = "Math",
                TestNeeded2       = "English",
                TestNeeded3       = "German",
                FucaltyName       = "Math"
            };

            //Act
            await administratorService.CreateSpeciality(createSpeciality);

            //assert
            mockUnitOfWork.Verify(x => x.Commit(), Times.Once);
        }