public bool save(ref AppNotification data)
 {
     try
     {
         SqlCommand command;
         if (data == null)
         {
             throw new Exception("Null notification not allowed.");
         }
         if (String.IsNullOrEmpty(data.ntype))
         {
             data.ntype = "user";
         }
         if (data.userId == 0)
         {
         }
         data.updatedDate = DateTime.Now;
         if (data.id == 0)
         {
             data.createdDate = DateTime.Now;
             command          = data.InsertInto();
             data.id          = DBServer.ExecuteNScalar(command);
         }
         else
         {
             command = data.UpdateInto();
             DBServer.ExecuteNon(command);
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
 public bool save(AppPermission[] permissions, SqlTransaction transaction)
 {
     try
     {
         List <SqlCommand> commands = new List <SqlCommand>();
         foreach (var appPermission in permissions)
         {
             if (appPermission.id == 0)
             {
                 commands.Add(appPermission.InsertInto());
             }
             else
             {
                 commands.Add(permissions.UpdateInto());
             }
         }
         DBServer.ExecuteNScalar(commands, transaction);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }