예제 #1
0
 public static Auditory Convert(this DbAuditory auditory)
 {
     return(new Auditory()
     {
         Id = auditory.AuditoryId, Number = auditory.Number
     });
 }
예제 #2
0
        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);
        }