public static Auditory Convert(this DbAuditory auditory) { return(new Auditory() { Id = auditory.AuditoryId, Number = auditory.Number }); }
public int AddAuditory(int number) { var item = Context.Auditories.FirstOrDefault(x => x.Number == number); if (item != null) { return(item.AuditoryId); } item = new DbAuditory() { Number = number }; Context.Auditories.Add(item); try { Context.SaveChanges(); } catch (Exception ex) { Debug.WriteLine($"Exception:{ex.Message}"); return(-1); } return(item.AuditoryId); }