public void DeleteAttendance(CACCCheckInDb.Attendance record)
        {
            logger.Debug("Opening DataContext to CACCCheckIn DB.");
            CACCCheckInDb.CACCCheckInDbDataContext db = new CACCCheckInDb.CACCCheckInDbDataContext();
            logger.DebugFormat("CACCCheckIn DB connection string: [{0}].", db.Connection.ConnectionString);
            db.Log = logwriter;

            try
            {
                logger.DebugFormat("Querying CACCCheckIn DB for Attendance with Date=[{0}], ClassId=[{1}] and PersonId=[{2}].",
                                   record.Date.ToShortDateString(), record.ClassId.ToString("B"), record.PersonId.ToString("B"));
                CACCCheckInDb.Attendance recordToDelete = (from r in db.Attendances
                                                           where r.Date.Equals(record.Date) &&
                                                           r.ClassId.Equals(record.ClassId) &&
                                                           r.PersonId.Equals(record.PersonId)
                                                           select r).Single <CACCCheckInDb.Attendance>();

                logger.DebugFormat("Deleting Attendance record for PersonId: [{0}]", record.PersonId);
                db.Attendances.DeleteOnSubmit(recordToDelete);

                db.SubmitChanges();
            }
            catch (ChangeConflictException ex)
            {
                logger.Error("ChangeConflictException:", ex);
                foreach (ObjectChangeConflict occ in db.ChangeConflicts)
                {
                    occ.Resolve(RefreshMode.OverwriteCurrentValues);
                }
            }
        }
        public CACCCheckInDb.Attendance UpdateAttendance(CACCCheckInDb.Attendance updatedRecord)
        {
            logger.Debug("Opening DataContext to CACCCheckIn DB.");
            CACCCheckInDb.CACCCheckInDbDataContext db = new CACCCheckInDb.CACCCheckInDbDataContext();
            logger.DebugFormat("CACCCheckIn DB connection string: [{0}].", db.Connection.ConnectionString);
            db.Log = logwriter;

            logger.DebugFormat("Querying CACCCheckIn DB for Attendance with Date=[{0}], ClassId=[{1}] and PersonId=[{2}].",
                               updatedRecord.Date.ToShortDateString(), updatedRecord.ClassId.ToString("B"), updatedRecord.PersonId.ToString("B"));
            CACCCheckInDb.Attendance currentRecord = (from r in db.Attendances
                                                      where r.Date.Equals(updatedRecord.Date) &&
                                                      r.ClassId.Equals(updatedRecord.ClassId) &&
                                                      r.PersonId.Equals(updatedRecord.PersonId)
                                                      select r).Single <CACCCheckInDb.Attendance>();

            logger.DebugFormat("Updating Attendance SecurityCode: [{0}]",
                               updatedRecord.SecurityCode);
            currentRecord.SecurityCode = updatedRecord.SecurityCode;

            db.SubmitChanges();

            return(db.Attendances.Where(r =>
                                        r.Date.Equals(updatedRecord.Date) &&
                                        r.ClassId.Equals(updatedRecord.ClassId) &&
                                        r.PersonId.Equals(updatedRecord.PersonId)).Single <CACCCheckInDb.Attendance>());
        }
Beispiel #3
0
        /// <summary>
        /// Deletes attendance record
        /// </summary>
        /// <param name="record"></param>
        private void DeleteAttendance(CACCCheckInDb.Attendance record)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.DeleteAttendance(record);
            }
        }
Beispiel #4
0
        public void DeleteAttendance(CACCCheckInDb.Attendance record)
        {
            Stopwatch sw = new Stopwatch();

            try
            {
                sw.Start();
                Channel.DeleteAttendance(record);
            }
            finally
            {
                sw.Stop();
                logger.DebugFormat("Call to CACCCheckInService.DeleteAttendance took [{0}] ms",
                                   sw.ElapsedMilliseconds);
            }
        }
Beispiel #5
0
        public CACCCheckInDb.Attendance UpdateAttendance(CACCCheckInDb.Attendance updatedRecord)
        {
            Stopwatch sw = new Stopwatch();

            try
            {
                sw.Start();
                return(Channel.UpdateAttendance(updatedRecord));
            }
            finally
            {
                sw.Stop();
                logger.DebugFormat("Call to CACCCheckInService.UpdateAttendance took [{0}] ms",
                                   sw.ElapsedMilliseconds);
            }
        }
        public CACCCheckInDb.Attendance InsertAttendance(CACCCheckInDb.Attendance record)
        {
            logger.Debug("Opening DataContext to CACCCheckIn DB.");
            CACCCheckInDb.CACCCheckInDbDataContext db = new CACCCheckInDb.CACCCheckInDbDataContext();
            logger.DebugFormat("CACCCheckIn DB connection string: [{0}].", db.Connection.ConnectionString);
            db.Log = logwriter;

            logger.DebugFormat("Inserting Attendance for PersonId: [{0}]", record.PersonId.ToString("B"));
            db.Attendances.InsertOnSubmit(record);

            db.SubmitChanges();

            return(db.Attendances.Where(r =>
                                        r.Date.Equals(record.Date) &&
                                        r.ClassId.Equals(record.ClassId) &&
                                        r.PersonId.Equals(record.PersonId)).Single <CACCCheckInDb.Attendance>());
        }