public ActionResult Create(SectionViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    tb_section section = new tb_section
                    {
                        section_title       = model.section_title,
                        section_description = model.section_description
                    };

                    sectionRepository.Add(section);
                    sectionRepository.Save();
                    @ViewBag.Message = "<div class=\"alert alert-success\">!! La section a ete sauvegardee avec succes </div>";
                    //use tempdata
                    return(RedirectToAction("Index", "Section"));
                }
                catch (Exception exp)
                {
                    ViewBag.Message = exp.Message;
                }
            }

            return(View(model));
        }
Example #2
0
        public async Task Create(CreateSectionDto section)
        {
            var clase = await _classRepository.FindById(section.Class);

            var period = await _periodRepository.FindById(section.Period);

            var professor = await _professorRepository.FindById(section.Professor);

            var sectionInfo = new Section
            {
                Code      = section.Code,
                Professor = professor,
                Period    = period,
                Class     = clase,
            };

            if (section.Students != null && section.Students.Count() > 0)
            {
                var students = _studentRepository.Filter(student => section.Students.Contains(student.Account)).ToList();

                foreach (var student in students)
                {
                    sectionInfo.StudentSections.Add(new StudentSection {
                        Student = student
                    });
                }
            }

            await _sectionRepository.Add(sectionInfo);
        }
Example #3
0
 public ActionResult Create(SectionViewModel sectionvm)
 {
     if (ModelState.IsValid)
     {
         sectionRepository.Add(sectionvm.ToOrm());
         return(RedirectToRoute(new { controller = "Section", Action = "Index" }));
     }
     return(View(sectionvm));
 }
Example #4
0
        public async Task <GetSectionResource> CreateSection(SetSectionResource sectionResource)
        {
            var resultGroupe     = new Groupe();
            var resultSousGroupe = new SousGroupe();

            //CreateSection
            var resultSection = _mapper.Map <SetSectionResource, Section>(sectionResource);

            _sectionrepository.Add(resultSection);
            await _unitOfWork.CompleteAsync();

            //CreateSectionGroupe
            resultGroupe =
                new Groupe
            {
                RefGroupe = "G1",
                SectionId = resultSection.Id
            };
            _groupeRepository.Add(resultGroupe);
            await _unitOfWork.CompleteAsync();

            //CreateGroupeSousGroupe
            resultSousGroupe =
                new SousGroupe
            {
                RefSousGroupe = "SG1",
                GroupeId      = resultGroupe.Id
            };
            _sGroupeRepository.Add(resultSousGroupe);
            await _unitOfWork.CompleteAsync();

            //JoinThem
            resultGroupe.SousGroupes.Add(resultSousGroupe);
            resultSection.Groupes.Add(resultGroupe);

            return(_mapper.Map <Section, GetSectionResource>(resultSection));
        }
Example #5
0
        public BanicoMutation(
            ISectionRepository sectionRepository,
            ISectionItemRepository sectionItemRepository,
            IContentItemRepository contentItemRepository
            )
        {
            Name = "BanicoMutation";

            Field <SectionType>(
                "addSection",
                arguments: new QueryArguments(
                    // <SectionInputType>
                    new QueryArgument <NonNullGraphType <SectionInputType> > {
                Name = "section"
            }
                    ),
                resolve: context =>
            {
                var section = context.GetArgument <Section>("section");
                return(sectionRepository.Add(section));
            });

            Field <SectionItemType>(
                "addSectionItem",
                arguments: new QueryArguments(
                    // <SectionInputType>
                    new QueryArgument <NonNullGraphType <SectionItemInputType> > {
                Name = "sectionItem"
            }
                    ),
                resolve: context =>
            {
                var sectionItem = context.GetArgument <SectionItem>("sectionItem");
                return(sectionItemRepository.Add(sectionItem));
            });

            Field <ContentItemType>(
                "addContentItem",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ContentItemInputType> > {
                Name = "contentItem"
            }
                    ),
                resolve: context =>
            {
                var contentItem = context.GetArgument <ContentItem>("contentItem");
                return(contentItemRepository.Add(contentItem));
            });

            Field <ContentItemType>(
                "updateContentItem",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ContentItemInputType> > {
                Name = "contentItem"
            }
                    ),
                resolve: context =>
            {
                var contentItem = context.GetArgument <ContentItem>("contentItem");
                return(contentItemRepository.Update(contentItem));
            });
        }
        public int Add(SectionDto sectionDto)
        {
            var conference = _mapper.Map <Section>(sectionDto);

            return(_sectionRepository.Add(conference));
        }
Example #7
0
 public void CreateSection(Section section)
 {
     sectionRepository.Add(section);
 }