コード例 #1
0
        public static void Update(ReportFile newRF)
        {
            try
            {
                if (newRF == null)
                {
                    throw new Exception("The 'ReportFile' entity does not contain any data!");
                }

                using (var context = new CompteResultatEntities())
                {
                    ReportFile oldRF = context.ReportFiles.Where(r => r.Id == newRF.Id).First();

                    oldRF.FileLocation = newRF.FileLocation;
                    oldRF.FileType     = newRF.FileType;
                    oldRF.CRId         = newRF.CRId;

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
        }
コード例 #2
0
        public static int Insert(ReportFile reportFile)
        {
            try
            {
                using (var context = new CompteResultatEntities())
                {
                    context.ReportFiles.Add(reportFile);
                    context.SaveChanges();

                    return(reportFile.Id);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
        }