Ejemplo n.º 1
0
 public static void Fill(this Contracts.Soa.SoaChapter soaChapter, Soa dbSoa, UserService userService)
 {
     soaChapter.Compliance         = dbSoa.Compliance;
     soaChapter.ComplianceDate     = dbSoa.ComplianceDate;
     soaChapter.Contractual        = dbSoa.Contractual;
     soaChapter.ControlDescription = dbSoa.ControlDescription;
     soaChapter.CurrentControl     = dbSoa.CurrentControl;
     soaChapter.DataProtectionLaw  = dbSoa.DataProtectionLaw;
     soaChapter.ImplementationDate = dbSoa.ImplementationDate;
     if (dbSoa.ImplementationUserId.HasValue)
     {
         soaChapter.ImplementationUser = userService.GetUserByUserId(dbSoa.ImplementationUserId.Value, false);
     }
     if (dbSoa.ResponsibleUserId.HasValue)
     {
         soaChapter.ResponsibleUser = userService.GetUserByUserId(dbSoa.ResponsibleUserId.Value, false);
     }
     soaChapter.Reason          = dbSoa.Reason;
     soaChapter.Relevance       = dbSoa.Relevance;
     soaChapter.RiskAssessments = dbSoa.RiskAssessments;
     soaChapter.SourceReference = dbSoa.SourceReference;
     soaChapter.SoaId           = dbSoa.SoaId;
     soaChapter.Integrity       = dbSoa.Integrity;
     soaChapter.Availability    = dbSoa.Availability;
     soaChapter.Authenticity    = dbSoa.Authenticity;
     soaChapter.Confidenciality = dbSoa.Confidenciality;
     soaChapter.SoaType         = dbSoa.SoaType;
     soaChapter.SoaLinks        = dbSoa.SoaLinks.Select(l => l.ToContract()).ToList();
 }
Ejemplo n.º 2
0
        public static void UpdateFrom(this Soa dbSoa, Contracts.Soa.SoaChapter soa, RAAPEntities db)
        {
            dbSoa.Compliance           = soa.Compliance;
            dbSoa.ComplianceDate       = soa.ComplianceDate;
            dbSoa.Contractual          = soa.Contractual;
            dbSoa.ControlDescription   = soa.ControlDescription;
            dbSoa.CurrentControl       = soa.CurrentControl;
            dbSoa.DataProtectionLaw    = soa.DataProtectionLaw;
            dbSoa.ImplementationDate   = soa.ImplementationDate;
            dbSoa.ImplementationUserId = soa.ImplementationUser?.UserId;
            dbSoa.ResponsibleUserId    = soa.ResponsibleUser?.UserId;
            dbSoa.Reason          = (int)soa.Reason;
            dbSoa.Relevance       = soa.Relevance;
            dbSoa.RiskAssessments = soa.RiskAssessments;
            dbSoa.SourceReference = soa.SourceReference;
            dbSoa.Confidenciality = soa.Confidenciality;
            dbSoa.Availability    = soa.Availability;
            dbSoa.Authenticity    = soa.Authenticity;
            dbSoa.Integrity       = soa.Integrity;
            db.SoaLinks.RemoveRange(dbSoa.SoaLinks.ToList());
            soa.SoaLinks.ForEach(l => dbSoa.SoaLinks.Add(l.ToDataModel(dbSoa)));
            var errors = dbSoa.SoaLinks.Where(s => s.Soa == null).ToList();

            if (errors.Count > 0)
            {
                string errormsg = "F**k shit shit!";
            }
        }
Ejemplo n.º 3
0
 public static Soa ToSoaDataModel(this Contracts.Soa.SoaChapter soa)
 {
     return(new Soa()
     {
         Compliance = soa.Compliance,
         ComplianceDate = soa.ComplianceDate,
         Contractual = soa.Contractual,
         ControlDescription = soa.ControlDescription,
         CurrentControl = soa.CurrentControl,
         DataProtectionLaw = soa.DataProtectionLaw,
         ImplementationDate = soa.ImplementationDate,
         ImplementationUserId = soa.ImplementationUser?.UserId,
         Reason = (int)soa.Reason,
         Relevance = soa.Relevance,
         ResponsibleUserId = soa.ResponsibleUser?.UserId,
         RiskAssessments = soa.RiskAssessments,
         SoaChapterId = soa.Id,
         SourceReference = soa.SourceReference,
         Authenticity = soa.Integrity,
         Availability = soa.Availability,
         Confidenciality = soa.Confidenciality,
         Integrity = soa.Integrity,
         SoaId = soa.SoaId,
         SoaType = soa.SoaType,
     });
 }
Ejemplo n.º 4
0
        public static void UpdateFrom(this SoaChapter dbSoaChapter, Contracts.Soa.SoaChapter soaChapter, string isoCode)
        {
            var dbSoaChapterItem = dbSoaChapter.SoaChapterItems.FirstOrDefault(i => i.IsoCode == isoCode);

            if (dbSoaChapterItem == null)
            {
                dbSoaChapterItem = new SoaChapterItem();
                dbSoaChapter.SoaChapterItems.Add(dbSoaChapterItem);
            }
            dbSoaChapterItem.Name        = soaChapter.Name;
            dbSoaChapterItem.Description = soaChapter.Description;
            dbSoaChapterItem.Goal        = soaChapter.Goal;
            dbSoaChapterItem.HowTo       = soaChapter.HowTo;
            dbSoaChapterItem.Info        = soaChapter.Info;
        }
Ejemplo n.º 5
0
        internal Contracts.Soa.SoaChapter AddTemplate(Contracts.Soa.SoaChapter soa)
        {
            var isoCode = soa.IsoCode;

            if (soa.SoaType == 3)
            {
                using (var db = new RAAPMasterEntities())
                {
                    var chapter = soa.ToDataModel(null, db, isoCode);
                    db.SoaChapters.Add(chapter);
                    db.SaveChanges();
                    return(chapter.ToContract(isoCode));
                }
            }
            else
            {
                throw new ArgumentException("Invalid SoaType", "SoaType");
            }
        }
Ejemplo n.º 6
0
        public static SoaChapter ToDataModel(this Contracts.Soa.SoaChapter soaChapter, SoaChapter parentSoaChapter, RAAPMasterEntities db, string isoCode)
        {
            var dbSoaChapter = new SoaChapter()
            {
                ParentChapter = parentSoaChapter,
                SoaType       = soaChapter.SoaType,
            };
            var dbSoaChapterItem = new SoaChapterItem()
            {
                Name        = soaChapter.Name,
                Description = soaChapter.Description,
                Goal        = soaChapter.Goal,
                HowTo       = soaChapter.HowTo,
                Info        = soaChapter.Info,
                IsoCode     = isoCode,
            };

            dbSoaChapter.SoaChapterItems.Add(dbSoaChapterItem);
            //db.SaveChanges(); //<-not optimal, but need to save parent chapters to make recursive linking work... :/
            soaChapter.SubChapters.ForEach(c => c.ToDataModel(dbSoaChapter, db, isoCode));
            return(dbSoaChapter);
        }
Ejemplo n.º 7
0
        public IHttpActionResult AddTemplate([FromBody] Contracts.Soa.SoaChapter soa)
        {
            var result = SoaService.AddTemplate(soa);

            return(Ok(result));
        }