public Models.Semester CreateSemester(Guid organizationId, string name, string shortName, string HighlightColor, bool isActive) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (organizationId == null || organizationId == System.Guid.Empty) { throw new ArgumentNullException("organizationId"); } Models.Semester semester = new Models.Semester() { Id = Guid.NewGuid(), OrganizationId = organizationId, Name = name, ShortName = shortName, HighlightColor = HighlightColor, IsActive = isActive, IsDeleted = false }; this.DataContext.Insert <Models.Semester>(semester); return(this.DataContext.Insert <Models.Semester>(semester)); ; }
public Models.Semester UpdateSemester(Guid id, string name, string shortName, string HighlightColor, bool isActive) { Models.Semester semester = this.GetById(id); if (semester == null) { throw new InvalidOperationException($"Semester ({id}) does not exist."); } semester.Name = name; semester.ShortName = shortName; semester.HighlightColor = HighlightColor; semester.IsActive = isActive; this.DataContext.Update <Models.Semester, Guid>(semester, x => x.Name, x => x.ShortName, x => x.HighlightColor, x => x.IsActive); return(semester); }