Esempio n. 1
0
        public ActionResult Create(CreateSectionViewModel createSection)
        {
            var createSectionDto = Mapper.Map <CreateSectionDto>(createSection);

            _sectionService.CreateSection(createSectionDto);
            return(RedirectToAction("Item", "SectionList", new { Id = createSection.SectionListId }));
        }
        public async Task <ActionResult> Edit(int id, CreateSectionViewModel sectionViewModel)
        {
            var temp = await _sectionService.FindById(id);

            var existingCode = await _sectionService.FindByCode(sectionViewModel.Code);

            if (existingCode == null || existingCode.Code == temp.Code)
            {
                var section = new UpdateSectionDto()
                {
                    Code      = sectionViewModel.Code,
                    Class     = sectionViewModel.Class,
                    Period    = sectionViewModel.Period,
                    Professor = sectionViewModel.Professor,
                    Students  = sectionViewModel.Students
                };
                await _sectionService.Update(id, section);

                return(Ok());
            }
            else
            {
                return(BadRequest("Ya existe una seccion con este codigo"));
            }
        }
Esempio n. 3
0
        public IActionResult CreateSection(string id)
        {
            CreateSectionViewModel model = new CreateSectionViewModel
            {
                GroupId = id
            };

            return(View(model));
        }
Esempio n. 4
0
        public IActionResult CreateSection(CreateSectionViewModel model)
        {
            if (ModelState.IsValid)
            {
                _doctrinaGroupRepository.CreateSection(model);

                return(RedirectToAction("Index", "Group", $"{model.GroupId}"));
            }

            return(View(model));
        }
Esempio n. 5
0
        public async Task <IActionResult> Index([FromBody] CreateSectionViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.Select(v => v.Errors)));
            }

            var section = _mapper.Map <Section>(vm);

            await _sectionsRepository.AddAsync(section);

            return(Ok());
        }
Esempio n. 6
0
        public JsonResult CreateSection(CreateSectionViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(JsonError(JsonRequestBehavior.DenyGet));
            }

            var newSectionNode =
                _mapper.Map <SectionNode, SectionNodeViewModel>(_sectionNodeService.CreateSectionNode(model.SectionTemplateId,
                                                                                                      model.DisplayName, model.UrlName));

            return(Json(newSectionNode, JsonRequestBehavior.DenyGet));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create(CreateSectionViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            var accessToken = await HttpContext.GetTokenAsync("access_token");

            await _api.PostSection(vm, accessToken);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 8
0
        public async Task <ActionResult> CreateSection(CreateSectionViewModel createSectionViewModel)
        {
            var products = await productRepository.GetByIdsAsync(createSectionViewModel.ProductIds);

            if (products == null || products.Count != createSectionViewModel.ProductIds.Count)
            {
                return(BadRequest(new ValidationErrors("Not all products were found.")));
            }

            await sectionRepository.CreateAsync(createSectionViewModel.Title, products);

            return(NoContent());
        }
Esempio n. 9
0
        public async Task <IActionResult> Create(CreateSectionViewModel model)
        {
            if (ModelState.IsValid)
            {
                Section section = new Section {
                    Name = model.Name
                };
                await db.Sections.AddAsync(section);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public DoctrinaGroupSection CreateSection(CreateSectionViewModel model)
        {
            DoctrinaGroup currentGroup = this.GetGroup(model.GroupId);

            DoctrinaGroupSection newSection = new DoctrinaGroupSection
            {
                Name          = model.Name,
                DoctrinaGroup = currentGroup
            };

            _db.Add <DoctrinaGroupSection>(newSection);
            _db.SaveChanges();

            string folderPath = Path.Combine(_hostingEnvironment.WebRootPath, $"DynamicResources/groups/{currentGroup.Id}/{newSection.Id}");

            Directory.CreateDirectory(folderPath);

            return(newSection);
        }
Esempio n. 11
0
        public async Task <IActionResult> Create(CreateSectionViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            using (var client = _clientFactory.CreateClient())
            {
                var accessToken = await HttpContext.GetTokenAsync("access_token");

                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

                var response = await client.PostAsync("https://localhost:44317/api/sections",
                                                      new StringContent(JsonConvert.SerializeObject(vm),
                                                                        Encoding.UTF8, "application/json")).ConfigureAwait(true);

                response.EnsureSuccessStatusCode();

                return(RedirectToAction(nameof(Index)));
            }
        }
        public async Task <ActionResult> Create(CreateSectionViewModel sectionViewModel)
        {
            var existingCode = await _sectionService.FindByCode(sectionViewModel.Code);

            if (existingCode == null)
            {
                var section = new CreateSectionDto
                {
                    Code      = sectionViewModel.Code,
                    Class     = sectionViewModel.Class,
                    Period    = sectionViewModel.Period,
                    Professor = sectionViewModel.Professor,
                    Students  = sectionViewModel.Students
                };
                await _sectionService.Create(section);

                return(Ok());
            }
            else
            {
                return(BadRequest("Ya existe una seccion con este codigo"));
            }
        }
Esempio n. 13
0
        // POST api/<controller>
        public void Post(CreateSectionViewModel createSectionView)
        {
            var creaeSectionDto = Mapper.Map <CreateSectionDto>(createSectionView);

            _sectionService.CreateSection(creaeSectionDto);
        }