public IHttpActionResult PostSection(SectionEntryModel sectionModel) { var section = new Section(); _sectionServices.Map(section, sectionModel); _sectionServices.Add(section); return(Ok(section)); }
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); } }
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); }
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(); } }
public IHttpActionResult PutSection(long sectionId, SectionEntryModel model) { var tmpSection = _sectionServices.UpdateSection(sectionId, model); return(Ok(tmpSection)); }