Ejemplo n.º 1
0
        public bool UpdateRecord(SampleDataModel Rec)
        {
            bool rslt             = false;
            AuditTestEntities ent = new AuditTestEntities();
            var dbRec             = ent.SampleData.FirstOrDefault(s => s.ID == Rec.ID);

            if (dbRec != null)
            {
                // audit process 1 - gather old values
                SampleDataModel OldRecord = new SampleDataModel();
                OldRecord.ID          = dbRec.ID;
                OldRecord.FirstName   = dbRec.FirstName;
                OldRecord.lastname    = dbRec.LastName;
                OldRecord.DateOfBirth = dbRec.DateOfBirth;
                // update the live record
                dbRec.FirstName   = Rec.FirstName;
                dbRec.LastName    = Rec.lastname;
                dbRec.DateOfBirth = Rec.DateOfBirth;
                ent.SaveChanges();

                CreateAuditTrail(AuditActionType.Update, Rec.ID, OldRecord, Rec);

                rslt = true;
            }
            return(rslt);
        }
Ejemplo n.º 2
0
        public List <SampleDataModel> GetAllData(bool ShowDeleted)
        {
            List <SampleDataModel> rslt          = new List <SampleDataModel>();
            AuditTestEntities      ent           = new AuditTestEntities();
            List <SampleData>      SearchResults = new List <SampleData>();

            if (ShowDeleted)
            {
                SearchResults = ent.SampleData.ToList();
            }
            else
            {
                SearchResults = ent.SampleData.Where(s => s.Deleted == false).ToList();
            }

            foreach (var record in SearchResults)
            {
                SampleDataModel rec = new SampleDataModel();
                rec.ID          = record.ID;
                rec.FirstName   = record.FirstName;
                rec.lastname    = record.LastName;
                rec.DateOfBirth = record.DateOfBirth;
                rec.Deleted     = record.Deleted;
                rslt.Add(rec);
            }
            return(rslt);
        }
Ejemplo n.º 3
0
        public void CreateRecord(SampleDataModel Rec)
        {
            AuditTestEntities ent   = new AuditTestEntities();
            SampleData        dbRec = new SampleData();

            dbRec.FirstName   = Rec.FirstName;
            dbRec.LastName    = Rec.lastname;
            dbRec.DateOfBirth = Rec.DateOfBirth;
            ent.SampleData.Add(dbRec);
            ent.SaveChanges();                         // save first so we get back the dbRec.ID for audit tracking
            SampleData DummyObject = new SampleData(); // Storage of this null object shows data before creation = nix, naught, nothing!

            CreateAuditTrail(AuditActionType.Create, dbRec.ID, DummyObject, dbRec);
        }
Ejemplo n.º 4
0
        public SampleDataModel GetData(int ID)
        {
            SampleDataModel   mod = new SampleDataModel();
            AuditTestEntities ent = new AuditTestEntities();
            SampleData        rec = ent.SampleData.FirstOrDefault(s => s.ID == ID);

            if (rec != null)
            {
                mod.ID          = rec.ID;
                mod.FirstName   = rec.FirstName;
                mod.lastname    = rec.LastName;
                mod.DateOfBirth = rec.DateOfBirth;
            }
            return(mod);
        }