示例#1
0
 public static void Insert(Model.Entities.LogDado logDado)
 {
     using (Context db = new Context())
     {
         using (var trans = new RP.DataAccess.RPTransactionScope(db))
         {
             db.LogDados.Add(logDado);
             db.SaveChanges(logDado.idUsuario);
             trans.Complete();
         }
     }
 }
        private void AtualizarPefis(Usuario usuario)
        {
            try
            {
                if (usuario == null || usuario.idUsuario == 0)
                {
                    throw new Exception("Informe o usuário");
                }

                using (Context db = new Context())
                {
                    using (var ts = new RP.DataAccess.RPTransactionScope(db))
                    {

                        UsuarioBLL bll = new UsuarioBLL(db, -999);
                        bll.UpdatePerfis(usuario);

                        db.SaveChanges();
                        ts.Complete();
                    }
                }
            }
            catch (Exception e)
            {
                System.ServiceModel.Web.WebOperationContext ctx = System.ServiceModel.Web.WebOperationContext.Current;
                ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
                ctx.OutgoingResponse.StatusDescription = e.Message;
               // throw new System.ServiceModel.Web.WebFaultException<string>(e.Message, System.Net.HttpStatusCode.BadRequest);
            }
        }