public GJournal SaveJournal(GJournal journal) { var dbJournal = this._repository.GJournals.GetByIdTracking(journal.Id); dbJournal.RationalInfo = this._mapper.Map <RationalInfo>(journal.RationalInfo); dbJournal.ThesisPlan = this._mapper.Map <ThesisPlan>(journal.ThesisPlan); dbJournal.WorkPlans = this._mapper.Map <ICollection <WorkPlan> >(journal.WorkPlans); dbJournal.EducationYears = this._mapper.Map <ICollection <EducationPhase> >(journal.EducationYears); dbJournal.ExamsData = this._mapper.Map <ICollection <ExamInfo> >(journal.ExamsData); this._repository.Exams.DeleteExcept(dbJournal.ExamsData, journal.Id); this._repository.WorkPlans.DeleteExcept(dbJournal.WorkPlans, journal.Id); this._repository.EducationPhases.UpdateEducationPhases(dbJournal.EducationYears); this._context.SaveChanges(); return(this._mapper.Map <GJournal>(dbJournal)); }
public IActionResult Post([FromBody] GJournal journal) { var savedJournal = this._journalManager.SaveJournal(journal); return(Ok(new { Message = Config.SaveSuccess, Journal = savedJournal })); }