public void EditProtocol(ProtocolW protocolW)
        {
            var protocol = db.Protocols.Single(p => p.Id == protocolW.Id);

            db.ProtocolResults.RemoveRange(protocol.ProtocolResults);
            protocol.ProtocolResults.Clear();
            foreach (var item in protocolW.ProtocolResults)
            {
                protocol.ProtocolResults.Add(item);
            }
            db.ProtocolsRemarks.RemoveRange(protocol.ProtocolsRemarks);
            protocol.ProtocolsRemarks.Clear();
            var acreditedLevel = db.AcredetationLevels.Single(al => al.Level.Trim() == AcreditationLevels.Acredited);
            foreach (var item in protocolW.ProtocolsRemarksA)
            {
                item.AcredetationLevelId = acreditedLevel.Id;
                //for some reason the saveChanges doesnt populate the Remark object in the ProtocolsRemark and its
                //needed inside the protocol generating
                item.Remark = db.Remarks.Single(r => r.Id == item.RemarkId);
                protocol.ProtocolsRemarks.Add(item);
            }
            var notAcreditedLevel = db.AcredetationLevels.Single(al => al.Level.Trim() == AcreditationLevels.NotAcredited);
            foreach (var item in protocolW.ProtocolsRemarksB)
            {
                item.AcredetationLevelId = notAcreditedLevel.Id;
                //for some reason the saveChanges doesnt populate the Remark object in the ProtocolsRemark and its
                //needed inside the protocol generating
                item.Remark = db.Remarks.Single(r => r.Id == item.RemarkId);
                protocol.ProtocolsRemarks.Add(item);
            }

            protocol.IssuedDate = protocolW.IssuedDate.ToUniversalTime();
            protocol.TesterMKB = protocolW.TesterMKB;
            protocol.TesterFZH = protocolW.TesterFZH;
            protocol.LabLeader = protocolW.LabLeader;

            using (TransactionScope scope = new TransactionScope())
            {
                db.SaveChanges();
                GeneratePorotocolReport(protocol);

                scope.Complete();
            }
        }
        public void Create(ProtocolW protocolW)
        {
            var acreditedLevel = db.AcredetationLevels.Single(al => al.Level.Trim() == AcreditationLevels.Acredited);
            foreach (var remark in protocolW.ProtocolsRemarksA)
            {
                remark.AcredetationLevelId = acreditedLevel.Id;
                remark.Remark = db.Remarks.Single(r => r.Id == remark.RemarkId);
            }
            var notAcreditedLevel = db.AcredetationLevels.Single(al => al.Level.Trim() == AcreditationLevels.NotAcredited);
            foreach (var remark in protocolW.ProtocolsRemarksB)
            {
                remark.AcredetationLevelId = notAcreditedLevel.Id;
                remark.Remark = db.Remarks.Single(r => r.Id == remark.RemarkId);
            }

            var protocol = protocolW.ToBase();
            //protocol.IssuedDate = DateTime.Now.ToUniversalTime();
            protocol.IssuedDate = protocol.IssuedDate.ToUniversalTime();
            db.Protocols.Add(protocol);
            var request = db.Requests.Single(r => r.Id == protocol.RequestId);
            GeneratePorotocolReport(protocol, request);

            db.SaveChanges();
        }