private Measure CreateMeasure(dynamic json, int catalogId, int responsibleSubjectId, int?ideaId) { var measure = new Measure { Name = json.Name, CreationDate = DateTime.Now, DueDate = json.DueDate, Description = json.Description, Priority = json.Priority, Status = 0, ResponsibleSubject = _measureRepository.GetResponsibleSubjectById(responsibleSubjectId) }; _measureRepository.AddMeasure(measure); var catalog = _measureRepository.GetById(catalogId); catalog.Measures.Add(measure); if (ideaId != null && IdeaExists(ideaId)) { var idea = _measureRepository.GetIdeaById((int)ideaId); idea.Measures.Add(measure); idea.Status = 1; _measureRepository.Update(idea); _measureRepository.AddLink(idea, "Measures", measure); } _measureRepository.AddLink(catalog, "Measures", measure); _measureRepository.SetLink(measure, "ResponsibleSubject", measure.ResponsibleSubject); return(measure); }