コード例 #1
0
        public IHttpActionResult PostSection(SectionEntryModel sectionModel)
        {
            var section = new Section();

            _sectionServices.Map(section, sectionModel);
            _sectionServices.Add(section);
            return(Ok(section));
        }
コード例 #2
0
 public void PutMap(Section section, SectionEntryModel sectionModel)
 {
     section.Code = sectionModel.Code;
     if (section.Class == null || section.Class.Id != sectionModel.ClassId)
     {
         section.Class = _classServices.Find(sectionModel.ClassId);
     }
     if (section.User == null || section.User.AccountId != sectionModel.ProffesorAccountId)
     {
         section.User = _professorsServices.Find(sectionModel.ProffesorAccountId);
     }
 }
コード例 #3
0
        public Section UpdateSection(long sectionId, SectionEntryModel model)
        {
            var tmpSection = _sectionsRepository.Get(sectionId);

            if (tmpSection == null)
            {
                throw new NotFoundException("No se encontro la seccion");
            }
            PutMap(tmpSection, model);
            tmpSection.Id = sectionId;
            _sectionsRepository.Update(tmpSection);
            _sectionsRepository.Save();
            return(tmpSection);
        }
コード例 #4
0
 public void Map(Section section, SectionEntryModel sectionModel)
 {
     section.Code = sectionModel.Code;
     if (section.Class == null || section.Class.Id != sectionModel.ClassId)
     {
         section.Class = _classServices.Find(sectionModel.ClassId);
     }
     if (section.User == null || section.User.AccountId != sectionModel.ProffesorAccountId)
     {
         section.User = _professorsServices.Find(sectionModel.ProffesorAccountId);
     }
     section.Period = _periodsServices.GetCurrentPeriod();
     if (section.Period == null)
     {
         throw new NoCurrentPeriodException();
     }
 }
コード例 #5
0
        public IHttpActionResult PutSection(long sectionId, SectionEntryModel model)
        {
            var tmpSection = _sectionServices.UpdateSection(sectionId, model);

            return(Ok(tmpSection));
        }