コード例 #1
0
ファイル: Site.cs プロジェクト: Crisp771/Chc
        public Site CreateSite(Site site, int userId)
        {
            var newsite = new tblSite()
            {
                ActionDetails  = site.ActionDetails,
                Address        = site.Address,
                ContactDetails = site.ContactDetails,
                SICcode        = site.SICcode,
                SiteID         = site.SiteID,
                SiteName       = site.SiteName,
                Deleted        = site.Deleted
            };

            _context.tblSites.Add(newsite);
            _context.SaveChanges();

            var audit = new SiteAudit()
            {
                Event         = string.Format("Site {1} created with id {0}", newsite.SiteID, newsite.SiteName),
                EventDateTime = DateTime.Now,
                SiteID        = newsite.SiteID,
                UserID        = userId
            };

            audit.Audit();

            return(new Site(newsite));
        }
コード例 #2
0
ファイル: Site.cs プロジェクト: Crisp771/Chc
        public Site UpdateSite(Site site, int userId)
        {
            var oldsite = _context.tblSites.Find(site.SiteID);

            oldsite.ActionDetails  = site.ActionDetails;
            oldsite.Address        = site.Address;
            oldsite.ContactDetails = site.ContactDetails;
            oldsite.SICcode        = site.SICcode;
            oldsite.SiteID         = site.SiteID;
            oldsite.SiteName       = site.SiteName;
            oldsite.Deleted        = site.Deleted;

            _context.SaveChanges();

            var audit = new SiteAudit()
            {
                Event         = string.Format("Site {0} updated.", oldsite.SiteName),
                EventDateTime = DateTime.Now,
                SiteID        = oldsite.SiteID,
                UserID        = userId
            };

            audit.Audit();

            return(new Site(oldsite));
        }
コード例 #3
0
ファイル: SiteAudit.cs プロジェクト: Crisp771/Chc
        public SiteAudit Audit(SiteAudit siteAudit)
        {
            var newAudit = new tblSiteAudit()
            {
                Event         = siteAudit.Event,
                EventDateTime = siteAudit.EventDateTime,
                SiteAuditID   = siteAudit.SiteAuditID,
                SiteID        = siteAudit.SiteID,
                UserID        = siteAudit.UserID
            };

            _context.tblSiteAudits.Add(newAudit);
            _context.SaveChanges();
            return(new SiteAudit(newAudit));
        }