public void ApproveModel(Guid modelID, Guid approverID, string note)
        {
            using (new TransactionScope(TransactionScopeOption.Suppress))
            {
                var d = new ModelsDataContext();
                var o = d.BlockModels.Where(f => f.BlockModelID == modelID).Single();
                o.ApproverContactID = approverID;
                if (o.AuthorContactID.HasValue)
                    _userService.EmailUsers(_userService.GetUserEmails(new Guid[] { o.AuthorContactID.Value }), "Model approved", note);
                var n = new BlockModelMetadata();
                n.BlockModelMetadataID = Guid.NewGuid();
                n.BlockModelID = modelID;
                n.ParameterID = _privateServices.XODB_GUID_LOG;
                var oc = new Occurrence();
                oc.ID = Guid.NewGuid();
                oc.ContactID = o.ApproverContactID.Value;
                oc.Occurred = DateTime.UtcNow;
                oc.Status = (uint)Occurrence.StatusCode.OK;
                n.BlockModelMetadataText = oc.ToJson();
                d.BlockModelMetadatas.InsertOnSubmit(n);
                d.SubmitChanges();
            }

        }
 public void DenyModel(Guid modelID, Guid denierID, string error)
 {
     using (new TransactionScope(TransactionScopeOption.Suppress))
     {
         var d = new ModelsDataContext();
         var o = d.BlockModels.Where(f => f.BlockModelID == modelID && f.AuthorContactID != null).Select(f => (Guid)f.AuthorContactID).ToArray();
         _userService.EmailUsers(_userService.GetUserEmails(o), "Model not accepted", error);
         var n = new BlockModelMetadata();
         n.BlockModelMetadataID = Guid.NewGuid();
         n.BlockModelID = modelID;
         n.ParameterID = _privateServices.XODB_GUID_LOG;
         var oc = new Occurrence();
         oc.ID = Guid.NewGuid();
         oc.ContactID = denierID;
         oc.Occurred = DateTime.UtcNow;
         oc.Status = (uint)Occurrence.StatusCode.Notified;
         n.BlockModelMetadataText = oc.ToJson();
         d.BlockModelMetadatas.InsertOnSubmit(n);
         d.SubmitChanges();
     }
 }
 public void UpdateModelParameter(BlockModelParameterViewModel m)
 {
     using (new TransactionScope(TransactionScopeOption.Suppress))
     {
         var d = new ModelsDataContext();
         var x = from p in d.Parameters where p.ParameterID == m.ParameterID select p;
         var o = x.First();
         o.UnitID = m.UnitID;
         d.SubmitChanges();
     }
 }